Version Used: a2df65047264ed08fb3a985056085dbcee821253
C#
var b = 1 is 1 || 1 is 2;
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=
Also, 1 is int x should perhaps give a warning (1 is var x should not).
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 == does not produce any error.
Most helpful comment
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.