Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Does not support array of inline tables #7

Closed
abirmkj opened this issue Mar 21, 2016 · 3 comments
Closed

Does not support array of inline tables #7

abirmkj opened this issue Mar 21, 2016 · 3 comments
Assignees
Milestone

Comments

@abirmkj
Copy link

abirmkj commented Mar 21, 2016

The following example listed on the TOML v0.4.0 specs is parsed as an array instead of a table:
points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ]

This causes a parsing error when another table entry is specified. E.g.
points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ]
points = { x = 12, y = 42, z = 35 }

These lines need to be treated as regular array of tables; i.e.
[[points]]
x = 1
y = 2
z = 3

[[points]]
x = 7
...

@paiden paiden added this to the 0.4.2 milestone Mar 21, 2016
@paiden paiden self-assigned this Mar 28, 2016
@paiden
Copy link
Owner

paiden commented Mar 28, 2016

Hi,

your issue is absolutely valid and will be fixed soon.

But I'm not sure if your given example

points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] 
points = { x = 12, y = 42, z = 35 } 

is valid TOML because for the key 'points' the types 'table' and 'array of tables' would get mixed up.

What should work instead is something like:

points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] 
[[points]]
x = 12
y = 42
z = 35

For me, especially these lines of the TOML spec indicate that mixing 'array of tables' and 'tables' is not allowed.

# INVALID TOML DOC
[[fruit]]
  name = "apple"

  [[fruit.variety]]
    name = "red delicious"

  # This table conflicts with the previous table
  [fruit.variety]
    name = "granny smith"

Can you give me a hint, where in the TOML spec is stated, that your example is valid TOML?

From the current TOML spec (that is somewhat vague in the area of 'array of tables') I'm not even sure if the following should be allowed:

points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] 
points = [{x = 12, y = 42, z = 35}]

@abirmkj
Copy link
Author

abirmkj commented Mar 30, 2016

Hi paiden,

I share your confusion regarding the TOML spec on tables.

I agree with your assessment that my example should be invalid. And, as you pointed out, the alternative valid scenario should be:

points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] 
[[points]]
x = 12
y = 42
z = 35

Clearly, we are not alone in our doubts regarding the usage of 'array of tables'; there is at least one recent discussion on the TOML page here: toml-lang/toml#309

Perhaps someone on the toml-lang group can resolve this? I'm curious to know the valid usage scenarios.

paiden added a commit that referenced this issue Apr 2, 2016
@paiden
Copy link
Owner

paiden commented Apr 2, 2016

This issue should be fixed with 071161d.
At the moment he parser only accepts this fragment

points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] 
[[points]]
x = 12
y = 42
z = 35

as valid TOML. The other given examples given from previous comments are not accepted as valid TOML because handling those cases would cause somewhat weird code in the current parser implementation (as this would need different handling than the other TOML objects).

I hope the toml-lang guys really think hard about 'array of tables' as I really don't like the current specification.

I also hope at some point they will release an up to date EBNF grammar so that people implementing the TOML standard don't need to rely the textually written specification (that is ambiguous).

@paiden paiden closed this as completed Apr 2, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants