-
Notifications
You must be signed in to change notification settings - Fork 4k
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
No warning for identity pattern-matching comparison #16099
Labels
Area-Compilers
Feature Request
New Feature - Warning Waves
Warning Waves
New Language Feature - Pattern Matching
Pattern Matching
Milestone
Comments
Also, |
jcouv
added
Area-Compilers
New Language Feature - Pattern Matching
Pattern Matching
labels
Dec 27, 2016
FYI @gafter |
I imagine this is more likely to happen in a "warning wave" in a subsequent release, but I'll see if we can get it in to C# 7. |
Is this related to unreachable code detection (rel. #15489)? int M()
{
if(1 is 1) return 2;
} Same code with |
gafter
added a commit
to gafter/roslyn
that referenced
this issue
Apr 9, 2018
Both refutable and irrefutable is-pattern matches affect definite assignment: - an irrefutable match leaves pattern variables definitely assigned - a refutable match is an error Fixes dotnet#25890 Also, we check to see if a constant input makes the result refutable or irrefutable: - If a constant cannot match the pattern, we issue a warning - If a constant always matches a constant pattern, we issue a warning The latter two are subject to compat council approval. Fixes dotnet#16099
Fixed in #26035 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area-Compilers
Feature Request
New Feature - Warning Waves
Warning Waves
New Language Feature - Pattern Matching
Pattern Matching
Version Used: a2df650
Expected Behavior:
Warning: "The given expression is always / never equal to the provided value", just like
is
would when used with types.Actual Behavior:
No warnings
http://tryroslyn.azurewebsites.net/#b:master/f:r/K4Zwlgdg5gBAygTxAFwKYFsDcAoADsAIwBswBjGUogQxBBgGEYBvbGNmfYsmANwHswAExgBZABQBKZtgCQMnlQBOMAjAC8MAIwwwdbQB99WnXQBMOOao3bdOiMhiHjtwX0JFUOdjAC+2H0A=
The text was updated successfully, but these errors were encountered: