Skip to content
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

Add lsp range info for file load errors #7335

Merged

Conversation

faldor20
Copy link
Collaborator

This now makes the language server use the correct range when encountering a file load error.

So now parse errors won't all appear at the very top!

@faldor20 faldor20 marked this pull request as draft December 11, 2024 16:31
@faldor20 faldor20 marked this pull request as ready for review December 11, 2024 16:38
@faldor20 faldor20 force-pushed the add-lsp-range-info-for-file-load-errors- branch 2 times, most recently from 6af627a to 82f6d29 Compare December 11, 2024 16:44
Anton-4
Anton-4 previously approved these changes Dec 11, 2024
Copy link
Collaborator

@Anton-4 Anton-4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, just the test failures remaining

@faldor20 faldor20 force-pushed the add-lsp-range-info-for-file-load-errors- branch from d2b3733 to e698953 Compare December 12, 2024 01:28
@faldor20
Copy link
Collaborator Author

I don't really understand that fuzzing test, or how I could have broken it.

@smores56
Copy link
Collaborator

crates/compiler/load/build.rs Outdated Show resolved Hide resolved
.get_region()
.unwrap_or(Region::new(
roc_region::all::Position::new(0),
roc_region::all::Position::new(10000000),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will presumably make the whole screen red if we don't have a region. Maybe just the first char is a better default? If not, then maybe we should use usize::MAX instead of "some really big number".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USize max is a bad plan. Lsp and json goes to javascript which, we must remember stores numbers as 64bit float and that would overflow on a usezie from 64bit systems.

This is stupid large and should be fine in all practical applications, but I guess I could use f64max.

We do this because the main cases where we don't have a target it's because the whole document is cooked in some way.

As Anton mentioned in zulip, it's often hard to find these errors if they are just on line 1 or something. I agree. If the error is a blocker for even parsing which precludes any other errors, why not show the whole doc as an erorr

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess we don't care right, because it won't actually overflow it'll just be imprecise.. I still don't entirely trust it to handle super large numbers maybe I'm just too conservative 😅

I guess I worry the imprecision will do funky things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My arbitrary number should be about 10million chars is about 100k lines of code which is as much as anyone should ever need... 10k might be a little too small.

crates/language_server/src/convert.rs Outdated Show resolved Hide resolved
@smores56
Copy link
Collaborator

There's nothing blocking merging this IMO, but I didn't approve since there's a CI check failing. Feel free to ping me when that's fixed and I can approve without worry of the approval being dismissed by code changes.

@smores56
Copy link
Collaborator

Thanks so much for this change! I started working on this at one point because it's really annoying when this happens and I end up needing to run roc check in another terminal to figure out how to fix the issue.

@smores56
Copy link
Collaborator

Can you actually sign all of these commits @faldor20 ? https://github.com/roc-lang/roc/blob/main/CONTRIBUTING.md#commit-signing

@faldor20 faldor20 force-pushed the add-lsp-range-info-for-file-load-errors- branch from 1739859 to c731c5d Compare December 12, 2024 10:56
@faldor20
Copy link
Collaborator Author

there you go @smores56 I think it lost my signatures because I got github to rebase onto master

@faldor20 faldor20 enabled auto-merge December 12, 2024 10:57
@faldor20 faldor20 merged commit 27b36a8 into roc-lang:main Dec 12, 2024
19 checks passed
@faldor20 faldor20 deleted the add-lsp-range-info-for-file-load-errors- branch December 13, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants