Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with nested tables and arrays #16

Open
barrucadu opened this issue Jun 26, 2016 · 3 comments
Open

Bug with nested tables and arrays #16

barrucadu opened this issue Jun 26, 2016 · 3 comments

Comments

@barrucadu
Copy link

[[fruit.blah]]
  name = "apple"

  [fruit.blah.physical]
    color = "red"
    shape = "round"

[[fruit.blah]]
  name = "banana"

  [fruit.blah.physical]
    color = "yellow"
    shape = "bent"

From my reading of the toml spec, that should work, and give rise to the following JSON:

{  
   "fruit":{  
      "blah":[  
         {  
            "name":"apple",
            "physical":{  
               "color":"red",
               "shape":"round"
            }
         },
         {  
            "name":"banana",
            "physical":{  
               "color":"yellow",
               "shape":"bent"
            }
         }
      ]
   }
}

And tomlv accepts it:

$ tomlv -types fruit.toml                                                                                                                         ~
    fruit.blah                         ArrayHash
        fruit.blah.name                String
        fruit.blah.physical            Hash
            fruit.blah.physical.color  String
            fruit.blah.physical.shape  String
    fruit.blah                         ArrayHash
        fruit.blah.name                String
        fruit.blah.physical            Hash
            fruit.blah.physical.color  String
            fruit.blah.physical.shape  String

However attempting to parse with htoml gives Cannot redefine table ('fruit, blah, physical'.

@cies
Copy link
Owner

cies commented Jun 27, 2016

This is a very interesting issue. Thanks for reporting it.

@cies
Copy link
Owner

cies commented Jun 27, 2016

I've made a test case for it: https://github.com/cies/htoml/tree/fix/issue-16

@HuwCampbell This issue will need --as I can see it-- quite serious overhaul of the "implicitness tracking logic"; as we need to keep track of it "per array item". Any thoughts on this?

@HuwCampbell
Copy link
Contributor

I don't think it should be that complicated, could be such that sub tables of the table arrays are filtered out of the parser state each time a new table array item is declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants