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.
single_match: Lint structs and tuple structs #8395
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
single_match: Lint structs and tuple structs #8395
Changes from all commits
3ec903f
1907ff5
22a44b7
2d1546b
cd3857a
4873ca1
5fc50fe
3161389
49cb789
159037a
060957a
7fc3545
b6695b0
cd89b1f
791a74e
5104517
4fae6c0
6686c72
cc55a8c
635bb4d
d429906
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because we should lint bindings iff the
else
branch (right
pattern) contains wildcards only.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this function is needed since wilds and bindings are effectively the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle wildcards only when processing an
els
branch, because we cannot bind identifier to it.For example, we don't want to lint the following case:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can lint that case. The binding will be unused in the second branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work in such cases. We don't actually know, which branch will be
if
and which will beels
, so after this change we'll get a lot of false positives.I think, this out of scope of this PR, because it aims just to add support for
Struct
andTupleStruct
patterns.We could improve precision of this lint in different PR, right?