-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Labels on multiple source files #193
Comments
I tried to work around the issue by using related errors. It could work, but some adjustments would be required to the way related errors are displayed (or, most likely, I'd have to roll my own custom Using an example from my project:
It is unclear, from the graphical output, that the latter error is actually a sub-error of the first one. They have the same heading ( |
This seems related to #171! Maybe some input there would be helpful? |
#171 is indeed related to the possible workaround - I left some comments, but it looks quite promising already! What about the more architecturally-impactful approach (first-class support for label labels spanning multiple source files within the same error)? |
I think labels themselves spanning multiple files is a tough sell. Part of the point of miette is also to allow all this fancy error reporting with a simple data model, and attaching that to a nice proc macro. Miette used to be a bit more flexible about this stuff, but it was way more complex, and I'm more happy where it sits now. |
Rephrasing, just to make sure I understand the concern: you are worried that supporting labels across multiple files (a niche-r usecase) will impact the ergonomics of the most common usecase (single file), therefore making this a net-negative tradeoff? |
correct. Older versions of miette supported this, and it was more complicated than it was worth. I think exploring things like #171 and such is a better alternative here. |
You can actually have labels in multiple files with current miette. When #324 is merged it will even show the correct file header above each context. |
miette
supports adding multiple labels to an error, but there seems to be a baked-in assumption that all labels refer to the same source file.This is proving to be a limitation for a usecase of mine: highlight in the error both the usage location (i.e. where a function is called) and the definition location.
To make a practical example: report in an error a function parameter as being of the wrong type (by labelling the value passed in as parameter at the usage location) while reporting, alongside it, the expected parameter type in the definition location (once again using a label).
Is this too niche or would there be an interest in supporting it?
It would probably require a fair amount of breaking changes (e.g.
Diagnostic::source_code
could have to return an optional iterator, labels will have to store the associated source code, etc.).You can see a potential implementation approach in
ariadne
(their multifile code example). They render them sequentially:The text was updated successfully, but these errors were encountered: