jm / toml

Parse TOML. Like a bawss.
MIT License
151 stars 38 forks source link

Fails to build against parslet 1.7.1 #43

Closed cinemast closed 6 years ago

cinemast commented 8 years ago

Hi!

Can you probably make a sense out of the following build error?

NoMethodError: undefined method `map' for "strings"@50:Parslet::Slice

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818155

Thank you and Greetings Peter

cinemast commented 8 years ago

It appears this occurs when building against parslet 1.7.1.

boutil commented 8 years ago

Parslet 1.7 changed the way rules are inserted to give higher priority to new rules. To fix the problem, exchange the two rules for Table and TableArray in lib/toml/transform.rb

--- a/lib/toml/transformer.rb
+++ b/lib/toml/transformer.rb
@@ -92,23 +92,23 @@
     # Make key hashes (inside key_groups) just be strings
     rule(:key => simple(:k)) { k }

-    # Then objectify the key_groups
-    rule(:table => simple(:kg)) {
-      Table.new([kg.to_s])
-    }
-
     # Captures array-like key-groups
     rule(:table => subtree(:kg)) {
       Table.new(kg.map &:to_s)
     }

-    # Single name table-arrays
-    rule(:table_array => simple(:name)) {
-      TableArray.new([name.to_s])
+    # Then objectify the key_groups
+    rule(:table => simple(:kg)) {
+      Table.new([kg.to_s])
     }
+
     # Multi-part (a.b.c) table-arrays
     rule(:table_array => subtree(:names)) {
       TableArray.new(names.map &:to_s)
     }
+    # Single name table-arrays
+    rule(:table_array => simple(:name)) {
+      TableArray.new([name.to_s])
+    }
   end
 end
jm commented 6 years ago

Fixed with #49