False positive "expression is always false" warning
I just upgraded to ReSharper 8 and I see this "expression is always false" warning quite a bit. In 6.6 I was not seeing this so I would consider this a regression. Here is an example on how to reproduce this bug:
private bool flag;
private void DoSomeWork()
{
flag = true;
}
private void Run()
{
if (flag)
{
return;
}
DoSomeWork();
if (flag) // this is underlined as being always false, but as you can see, the DoSomeWork method changes it to true
{
}
}
This seems like a dangerous problem because you could end up erroneously deleting code that ReSharper marked as unnecessary but this could certainly change behavior at runtime. While I could disable the warning with a comment, ReSharper will always grey out the contents of the if block saying that the code is heuristically unreachable.
Please sign in to leave a comment.
Hi Jason,
Thanks for the report. I've confirmed and logged this issue here in YouTrack: http://youtrack.jetbrains.com/issue/RSRP-383012