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

Proper error message for non exhaustive match #1772

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Jan 23, 2024

Fixes #1771.

An argument to match expressions that wouldn't match any of the branches used to print a pretty bad error message ("expecting Enum, found Enum"). This commit creates a proper variant for non-matching expressions, and make the error reporting point to the match expression and to the value the argument evaluated to.

Currently, one position that might be lost in translation is where the match expression was applied to this argument. Here we only get the point where the match expression is defined, and what the argument evaluated to (often the application of the expression to the argument is close to the definition of the match expression, but not necessarily). The application site is a bit harder to track; for now, this PR is a trivial change and a strict improvement over the previous situation. Let's reconsider later if this proves insufficient.

Argument to match expressions that wouldn't match any of the branches
used to have a pretty bad error message ("expecting Enum, found Enum").
This commit creates a proper variant for non-matching expressions,
pointing to the match expression and to the value the argument evaluated
to.

Currently, one position that might be lost in translation is where the
match expression was applied. It's a bit harder to track; for now, this
commit is a trivial change and is a strict improvement over the previous
situation. Let's reconsider later if this is insufficient.
@yannham yannham requested review from vkleen and jneem January 23, 2024 11:44
@github-actions github-actions bot temporarily deployed to pull request January 23, 2024 11:49 Inactive
@yannham yannham added this pull request to the merge queue Jan 23, 2024
Merged via the queue into master with commit 4f84cf0 Jan 23, 2024
5 checks passed
@yannham yannham deleted the fix/match-error-message branch January 23, 2024 12:50
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.

Bad error message when enums do not match up
2 participants