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

Nested tables in arrays apply their keys to the array table, not its last element #20

Open
mattwidmann opened this issue Nov 19, 2018 · 0 comments

Comments

@mattwidmann
Copy link

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" },
}
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

Successfully merging a pull request may close this issue.

1 participant