This is based on this question, which seems to me a glitch in the language or a missing warning in the compiler. My reasoning is that is will always return true in expressions of the following type:
int i; if (i is var j) ....
Taking another step, consider the following code:
int i; if (i is int) ....
But, as with var , follow these steps:
if (i is int j) ... else ...
You will not receive a warning (no expression is always true or unreachable code found in the else clause), which is essentially the same behavior.
It makes me think, maybe my initial reasoning is wrong. Is there some obscure use / angle case that I'm missing if that really matters? And if not, is the missing warning and inconsistent behavior an oversight (or even an error) in the compiler?
source share