Proper error message for non exhaustive match #1772
Merged
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.
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.