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

Dotted keys can't define sub-tables within tables indirectly defined in header form #61

Closed
Validark opened this issue Sep 27, 2020 · 6 comments
Assignees
Labels
bug Something isn't working TOML spec An issue relating to the library's TOML spec conformance.

Comments

@Validark
Copy link

I believe based on the online library tester that this library fails to handle this valid TOML document:

[fruit.apple.texture]  # you can add sub-tables
smooth = true

[fruit]
apple.color = "red"
apple.taste.sweet = true

I haven't actually used this library outside of the browser, so all I got for you is a playground link: https://godbolt.org/z/T59E7d

Related: toml-lang/toml#771

@Validark Validark added the bug Something isn't working label Sep 27, 2020
@marzer
Copy link
Owner

marzer commented Sep 27, 2020

The behaviour is correct; that's not legal TOML. You can't mix [table.headers] and dotted.key.value = "pairs" like that.

The way to do this correctly would be:

[fruit.apple.texture]
smooth = true

[fruit.apple]
color = "red"
taste.sweet = true

Dotted keys are effectively just shorthand for creating nested inline tables.

@marzer marzer closed this as completed Sep 27, 2020
@marzer marzer added not a bug A bug report, wasnt. and removed bug Something isn't working labels Sep 27, 2020
@Validark
Copy link
Author

My mistake, I didn't scroll all the way down in toml-lang/toml#771 to see that this issue is still being debated.

@marzer
Copy link
Owner

marzer commented Sep 27, 2020

Aye, it's a pretty confusing part of the spec. Given the choice personally I'd remove dotted.key.value = "pairs" from the language entirely.

@awvwgk
Copy link

awvwgk commented Jan 13, 2021

I'm intrigued by this example, maybe I should rather ask this to the discussion in toml-lang/toml#769, but it seems more related to this particular implementation to me.

Why would this TOML document be invalid

[fruit.apple.texture]  # you can add sub-tables
smooth = true

[fruit]
apple.color = "red"
apple.taste.sweet = true

but changing the order of the tables be valid instead if dotted keys were shorthands for inline tables? https://godbolt.org/z/ss9xsP

[fruit]
apple.color = "red"
apple.taste.sweet = true

[fruit.apple.texture]  # you can add sub-tables
smooth = true

@marzer
Copy link
Owner

marzer commented Jan 13, 2021

but changing the order of the tables be valid

Well, yeah, it shouldn't be. I need to revisit this part of the code (and the spec!), evidently.

@marzer marzer reopened this Jan 14, 2021
@marzer marzer added bug Something isn't working TOML spec An issue relating to the library's TOML spec conformance. and removed not a bug A bug report, wasnt. labels Jan 14, 2021
@marzer marzer closed this as completed in b11f28a Jan 16, 2021
@marzer
Copy link
Owner

marzer commented Jan 16, 2021

This is fixed now, though won't find it's way into the online parser until whenever that next gets updated; I'm not the maintainer of that project.

(cc @bobfang1992)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working TOML spec An issue relating to the library's TOML spec conformance.
Projects
None yet
Development

No branches or pull requests

3 participants