-
Notifications
You must be signed in to change notification settings - Fork 190
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
Dumping should fail for lists with mixed data types #228
Comments
The TOML standard currently does not permit mixed-type arrays. To be compliant with TOML v0 5.0, yes, heterogenous arrays must throw an exception. It may be worth noting there's talk of allowing mixed types in arrays in future versions of the standard. It appears to be gaining traction, because of kludgey ways of working around the restriction and TOML's drift away from just being a configuration format. So far, allowing mixed types has not been approved. But for this project and others, I would recommend maintaining logic allowing for mixed types, even if it isn't always used. Depending on how the standard evolves, the current non-compliant behavior may still be useful. |
The problem I clearly demonstrated here is that the loader cannot round-trip (de)serialization of a particular input; regardless of current/future specification conformity this is a problem that can manifest as bugs for downstream packages that accept user-input that somehow successfully serializes but could not then reloaded. As it is now this also forces packages depending on |
It's not really an actual problem anymore, because with TOML version 1.0.0 values of different types may be mixed. Now different types can't be mixed, this problem is already illustrated here: #270 |
Indeed! I'll close this out in that case. :) |
Currently, the behavior of
dumps
on data that contain a list of mixed types will produce invalid toml serialization successfully instead of raising an exception. For example:Which naturally result in an invalid toml document that can't be loaded back:
Compared to the node implementation
@iarna/toml
which has a more compliant behavior on the same input:The text was updated successfully, but these errors were encountered: