-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Errors with zero-length span and no context lines are mostly pointless #355
Comments
I'm currently looking at implementing solution 1 with a |
Nahor
added a commit
to Nahor/miette
that referenced
this issue
Mar 11, 2024
…ent line" and "just the span" Fixes zkat#355 Change the number of context lines from usize to Option<usize> to allow choosing between "just the span" (as implemented previously when using 0 context line) using `None`, and displaying the error line without extra context (not possible before) using `Some(0)`.
Nahor
added a commit
to Nahor/miette
that referenced
this issue
Mar 11, 2024
…ent line" and "just the span" Fixes zkat#355 Change the number of context lines from usize to Option<usize> to allow choosing between "just the span" (as implemented previously when using 0 context line) using `None`, and displaying the error line without extra context (not possible before) using `Some(0)`.
Nahor
added a commit
to Nahor/miette
that referenced
this issue
Mar 20, 2024
…ent line" and "just the span" Fixes zkat#355 Change the number of context lines from usize to Option<usize> to allow choosing between "just the span" (as implemented previously when using 0 context line) using `None`, and displaying the error line without extra context (not possible before) using `Some(0)`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code
Result
Expected:
Problem
The issue is read_span with 0 context line returns just the content of the span, not the whole line. Since the span is 0-length, there is no content.
The alternative is to specify at least one context line, but that mean three lines will be display (1 before, error line, 1 after), which is more than what is wanted.
Also, this gets really weird when there are multiple 0-length spans, e.g. same as above but with a 2nd span/label at
(12, 0)
, the firste
inthree
:which ought to look like this:
Note how the second label doesn't show in the broken version, only the text just before it
Possible solutions:
read_span
andwith_context_lines
1 could take anOption<usize>
, so one could distinguish between "just the span content" (None
) and "just the error line" (Some(0)
). The drawback is an API break.Footnotes
or to reduce the amount of API breakage, add a
with_opt_context_lines(Option<usize>)
function and convertwith_context_lines(0)
intowith_opt_context_lines(None)
↩The text was updated successfully, but these errors were encountered: