-
Notifications
You must be signed in to change notification settings - Fork 106
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
Parse mode that returns all errors and an as-valid-as-possible Document #371
Comments
If I understand correctly, and the proposed solution is to add support for a non-standard flavor of Toml which is disabled by default. And the alternative solution is to improve the error message on duplicate keys. I'd be in favor of the latter. |
I'd rather we explore any other option before going down the route of We already need to add spans for fields. Once we have that, we could easily look up the first span and report both. We could then collect errors as we go, accumulating them, rather than stopping immediately. Some questions or concerns I have that would need to be addressed
|
For my projects it certainly won't be enough for me to care. Parsing would have to be maybe 1000x slower to be a problem. If it has to be behind a feature flag so that perf-sensitive people are not harmed, I will happily turn on the feature flag.
I believe so. I really don't like how rustc tries to recover syntactic errors causing printing of more errors that were caused by the syntactic ones.
In |
Cargo is the main performance-sensitive project that I'm aware of and we need to be sensitive to as it has to parse hundreds of toml files per invocation. I have been trying to nerd snipe the performance team into looking at this and seeing about doing a binary cache for immutable manifests (ie from a registry) |
Also, I'll note that my main toml-related priority right now is moving toml-rs to be on top of toml_edit. Anything related to this comes after for me, including reviewing people making changes to toml-rs as that takes both review time and is throwaway. |
Just noticed I forgot to say that returning error will prevent me from reporting all duplicates across different parts of the toml. So it's better than the current situation but worse than the ideal situation. And I guess adding logic to |
Something I've been considering is to expose error recovery to the caller. meaning we'd have something like |
Sounds interesting, what would the |
|
That sounds quite good, any reason to not return |
I'm assuming you are referring to the |
And to clarify, with us swapping |
Background
In
configure_me
I recently added support for very nice error messages usingcodespan-reporting
. One of the nice features is ability to report multiple errors. However the requirement to not duplicate keys degrades the experience. Note thatconfigure_me
input is even more strict: it requires that keys are not duplicate among multiple items. This is detected manually and produces output like this:As you can see, this is very programmer-friendly. Note that this also outputs other errors such as invalid names of parameters. However if you duplicate a key within a single table you get a message like this:
Not only does it limit the output to a single error, it's also missing information about which other place defines the same key and span points to a weird place as well.
Proposed solution
The easiest for me would be adding
set_allow_duplicate_keys()
method similar to the existing methods. Then the existing code would work just fine. The method should probably have documentation that users must reject duplicates themselves to adhere to Toml specification and the method is only provided for custom error handling.Alternative
I would find it understandable if you think that despite warnings in the doc people would abuse it to implement "robustness principle" which is actually quite bad. If you'd rather not provide an abuse-able tool then at least improving the error type to contain enough information to show all duplicated fields within a single map would be nice.
The text was updated successfully, but these errors were encountered: