-
Notifications
You must be signed in to change notification settings - Fork 846
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
Allow duplicate keys #697
Comments
You may be working with a non-compliant parser when you describe what you say used to work. But the specification is explicitly clear on this point:
And a TOML document with duplicated keys will always be invalid. There is no benefit in making things more elaborate than that. But, that wouldn't prevent you from loading two or more TOML documents and chaining them together in your application. Based on what you've written, I think you could define that chaining behavior pretty well. |
The one I said that is working are things that are okay according to the spec. adding elements to arrays. Basically my first sentence was that I'm aware that things that I am suggesting are currently against the spec, but unless there is an actual point on why it's defined like that (other than "no!"), I don't see why it wouldn't be beneficial to relax the restrictions to allow more flexibility. |
That makes sense, okay.
Flexibility comes at a cost. For instance, we have three ways of defining tables in the spec, and it took us a very long time to reach a consensus on the behaviors that these different syntaxes follow. For a standard whose core purpose is to be minimal and obvious, we bent over backwards to make it that much more flexible. |
I like this feature, but I think it should be optional. As in, the spec should word it as |
These rules can create an "action at a distance" behaviors, are context dependent and introduces complexity. All of these are things I'd like to avoid in TOML. Disallowing duplicate keys keeps the semantics simpler, making it easier for implementations, authors of configuration files and enhances readability. I'd like to preserve these behaviors. For users that want behaviors like you've described, they can use tables and have application-side logic for implementing such behaviors. TOML won't be introducing duplicate keys for such use-cases. |
I'm going to close this issue for this reason. |
Yeah, it's against the spec right now, but changing it shouldn't break any clients, since this used to be behaviour that broke.
Seems like there were a few questions raised before about this:
BurntSushi/toml#186
#350
For my use case I would like to be able to concatenate toml files (default.toml + override.toml), and end up with a valid toml file.
My take on the rules would be:
foo.bar = 42
), overwrite the valuefoo.bar = [1,2,3]
), that's a value definition see rule "Special Characters" is undefined. #1Let me know your thoughts.
The text was updated successfully, but these errors were encountered: