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

Sub-tables defined using both table and dotted keys are flagged as duplicates #8

Open
tpoliaw opened this issue Oct 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tpoliaw
Copy link

tpoliaw commented Oct 22, 2024

Describe the bug
If a table has some entries defined using dotted.syntax and some using [tables], they are flagged as duplicates and fail to parse. This is allowed in the spec (end of the table section) as The [table] form can, however, be used to define sub-tables within tables defined via dotted keys.

To Reproduce

fn main() {
    let src = r#"
        abc.foo = "one"
        [abc.bar]
        fizz = 1
        buzz = 2
        "#;
    let table = toml_span::parse(src);
    println!("{table:?}");
}
Gives the duplicate key error
Err(
    Error {
        kind: DuplicateKey {
            key: "abc",
            first: Span {
                start: 9,
                end: 12,
            },
        },
        span: Span {
            start: 34,
            end: 37,
        },
        line_info: Some(
            (
                2,
                9,
            ),
        ),
    },
)

Expected behavior
The above example to be parsed into the equivalent of {'abc': {'bar': {'fizz': 1, 'buzz': 2}, 'foo': 'one'}}

Device:

  • OS: Linux
  • Version 0.3.0
  • rustc 1.82.0
@tpoliaw tpoliaw added the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant