lua-toml
lua-toml copied to clipboard
Nested tables in arrays apply their keys to the array table, not its last element
Within an array of tables, a single-bracket table spec with the array's key should apply to its last element (https://github.com/toml-lang/toml#array-of-tables). Instead, lua-toml adds the new table's keys to the array table itself, making it a mixed sequence and associative table.
For example, given the following TOML:
[[people]]
first_name = "Bruce"
last_name = "Springsteen"
[people.birth]
date = "September 23, 1949"
place = "Long Branch, New Jersey"
[people.spouse]
first_name = "Patti"
last_name = "Scialfa"
[[people]]
# an empty element
[[people]]
first_name = "Eric"
last_name = "Clapton"
A parser should produce:
people = {
{
first_name = "Bruce", last_name = "Springsteen",
birth = {
date = "September 23, 1949",
place = "Long Branch, New Jersey"
},
spouse = { first_name = "Patti", last_name = "Scialfa" },
}, { -- empty element
}, {
first_name = "Eric", last_name = "Clapton"
}
}
But lua-toml 2.0.1 instead produces:
people = {
{
first_name = "Bruce", last_name = "Springsteen"
}, { -- empty element
}, {
first_name = "Eric", last_name = "Clapton"
},
birth = {
date = "September 23, 1949",
place = "Long Branch, New Jersey"
},
spouse = { first_name = "Patti", last_name = "Scialfa" },
}