Add index range hints for syntax errors/warnings in eval_string#8472
Open
isuffix wants to merge 1 commit into
Open
Add index range hints for syntax errors/warnings in eval_string#8472isuffix wants to merge 1 commit into
eval_string#8472isuffix wants to merge 1 commit into
Conversation
4ff6319 to
ce5ce7b
Compare
isuffix
commented
Jun 9, 2026
Comment on lines
384
to
390
| fn synthesize_with( | ||
| &mut self, | ||
| mut offset: usize, | ||
| map_span: &impl Fn(usize, usize) -> Span, | ||
| update_sub_range: &impl Fn(usize, &mut Option<SubRange>), | ||
| add_hint: &impl Fn(usize, usize) -> Option<EcoString>, | ||
| ) { |
Collaborator
Author
There was a problem hiding this comment.
This signature is starting to get unwieldy, but it would probably be more effort to duplicate it since the behaviors of synthesize and synthesize_mapped are still very similar.
ce5ce7b to
635dc32
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the
evalfunction, we set a synthetic span on the evaluated string, but this overrides the spans for error and warning diagnostics and leads to a pessimistic range on diagnostics. Improving these ranges would require a lot of effort, and is not even feasible at all in the general case, but there are some simpler improvements we can make.This PR takes the step of adding a hint to syntax errors and warnings containing the original index range of the diagnostic. This does not apply to evaluation errors like undefined variables, but is a step in the right direction.
This is an improvement for #7799, but is not a complete fix.
CC @JeppeKlitgaard