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

Improve experience for unhandled parse errors #7203

Merged
merged 11 commits into from
Nov 6, 2024
Merged

Conversation

agu-z
Copy link
Collaborator

@agu-z agu-z commented Nov 6, 2024

Quite a few unhandled syntax errors have accumulated over the years. It's easy to forget to handle these in reporting because we have wildcard match branches that just call todo!():

thread 'main' panicked at crates/reporting/src/error/parse.rs:681:14:
not yet implemented: unhandled parse error: Return(ReturnValue(Start(@11579), @11579), @11572)

That experience is pretty bad when you hit one. You don't know which file the error is in, and you only get byte offsets instead of a line and column.

We should handle all of those, but in the meantime, this PR removes all wildcard pattern matching on parser errors to prevent more cases from accumulating.

Furthermore, it improves the experience for the existing unhandled cases by printing a more intentional report that includes the file and region:

── UNHANDLED PARSE ERROR in src/Pg/BasicCliClient.roc ──────────────────────────

I got stuck while parsing this:

437│  return : a -> Task [Done a] *
             ^

Here's the internal parse problem:

    Return(ReturnValue(Start(@11579), @11579), @11572)

Unfortunately, I'm not able to provide a more insightful error message
for this syntax problem yet. This is considered a bug in the compiler.

Note: If you'd like to contribute to Roc, this would be a good first issue!                                                                                

Let me know what you think of that note. I thought it was a nice opportunity to encourage contributions, but I'm happy it to drop it if we don't want the compiler to do that.

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.

Thanks @agu-z :)

@agu-z agu-z merged commit 1a57766 into main Nov 6, 2024
18 checks passed
@agu-z agu-z deleted the improve-unhandled-syntax-err branch November 6, 2024 23:52
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.

2 participants