Does not support array of inline tables
abirmkj opened this issue · 3 comments
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
...
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}]
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.
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).