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

handle syntax errors more gracefully #34

Closed
wants to merge 3 commits into from

Conversation

aaronjanse
Copy link
Member

Fixes #33.

I don't know enough about rowan to cleanly improve error handling, but I thought I'd at least share the patch I've been using locally while implementing rnix-lsp autocomplete.

Feel free to re-use parts of this patch for a different PR, push directly to this PR, or something else.

@aaronjanse aaronjanse requested a review from Ma27 September 26, 2021 00:54
@aaronjanse aaronjanse changed the title handle syntax errors more gracefully [WIP] handle syntax errors more gracefully Sep 26, 2021
@Ma27 Ma27 added the bug Something isn't working label Oct 8, 2021
@Ma27 Ma27 added this to the 0.10.0 milestone Oct 8, 2021
@Ma27 Ma27 modified the milestones: 0.10.0, 0.11.0 Nov 30, 2021
Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

LGTM mostly, nice work! :)

Would you mind resolving the last comment and rebase?

let end = self.finish_error_node();
self.errors.push(ParseError::Expected(
TextRange::new(start, end),
"attribute".to_string(),
Copy link
Member

Choose a reason for hiding this comment

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

I guess we should reflect here that strings etc. are also OK.

Copy link
Member Author

Choose a reason for hiding this comment

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

What should be the exact message used? Maybe attribute or string? Although I guess a string does represent an attribute here? Please correct me if I'm wrong

@aaronjanse
Copy link
Member Author

I pushed a somewhat significant change to behavior. The change matters only for attr path now. I also added an "expected semicolon" error node and updated tests

@aaronjanse aaronjanse changed the title [WIP] handle syntax errors more gracefully handle syntax errors more gracefully Jul 26, 2022
@oberblastmeister
Copy link
Contributor

You need to run this with a fuzzer. Adding better error handling can easily screw up the parser, and I got an out of memory error relatively quickly. I would prefer more general error handling (removing expect_peek_any). It would be also be good to see the effectiveness of the error handling by hooking it up with rnix-lsp. Maybe a mono repo would be good for this?

@aaronjanse
Copy link
Member Author

Wow, good catch @oberblastmeister. The fuzzer is amazing, and after seeings its result, I agree that we need a more general solution here. I'll start working on that. Thank you!!

@aaronjanse aaronjanse closed this Jul 27, 2022
@oberblastmeister
Copy link
Contributor

@aaronjanse I already did a lot of work here #35. Also, I really think we should work on hooking up the new version of rnix to rnix-lsp before we do improved error handling. This way we can try out the error handling in real time.

@aaronjanse
Copy link
Member Author

@aaronjanse I already did a lot of work here #35

Oh, sorry about that! I'm still catching up after being away for a while. If you submit a PR for the error handling that was in #35, I'll close #120 in favor of your PR.

I really think we should work on hooking up the new version of rnix to rnix-lsp before we do improved error handling. This way we can try out the error handling in real time.

As in, you think we should update rnix-lsp to use the latest nix-parser version? I'd be willing to work on doing that

@oberblastmeister
Copy link
Contributor

As in, you think we should update rnix-lsp to use the latest nix-parser version? I'd be willing to work on doing that

Yes! I think that would be great.

@aaronjanse
Copy link
Member Author

Sounds good, will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error handling for Select expressions
3 participants