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 missing pattern suggestions for empty case expressions with multiple subjects #3569

Open
GearsDatapacks opened this issue Aug 27, 2024 · 0 comments
Labels
help wanted Contributions encouraged priority:medium

Comments

@GearsDatapacks
Copy link
Contributor

When there is a case expression with no matched patterns, we attempt to improve the error by running the first column through exhaustiveness checking (See #3561, here).
This works fine, for example, matching on values of type Bool, Result(_, _) suggest True, _ and False, _.

This could be improved to suggest all four possible patterns, although as discussed in the above PR, this grows exponentially, so maybe requires more discussion.
But one way it could definitely be improved is the following:
When matching on values of type, for example, Int, Bool, where the first type has infinite patterns, it only suggests _, _, since only the first subject is checked.

My suggestion for this is to do checking for all subjects, but cap the maximum number of paths, at say 64, so we don't end up emitting thousands of missing patterns. (Rust Analyzer does this, though I don't remember what the number is).
That way we get good suggestions without overrunning the user with too many patterns.

@lpil lpil added help wanted Contributions encouraged priority:medium labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions encouraged priority:medium
Projects
None yet
Development

No branches or pull requests

2 participants