Skip to content

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

Description

@mattwidmann

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions