R# bug where it says a variable is always false
Bug in the link below
http://content.screencast.com/users/BuckleyORB/folders/Jing/media/b2d89d77-e90f-4b30-a6e9-3242c269cedf/2008-09-26_1645.png
I have isolated it from other code so the code doesn't makes sense now. The stucture is the same though.
Please sign in to leave a comment.
Tom, I used almost similar code to yours in a console application and I don't get any tooltip. My RS options allow for expression is always true or false as a warning but to all intent it sees nothing 'wrong'. If I comment out the ic = true statement then it does tell me the expression is always false. I'm using RS build 4.0.819.19.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
bool ic = false;
try
{
ic = true;
amethod();
return;
}
catch(Exception)
{
if(ic)
{
Console.WriteLine("ic is true");
}
}
}
private static void amethod()
{
throw new Exception();
}
}
}
Coming back to your screenshot upload I'm also curious why your invoiceCreated = true statement appears light gray when all other statements appear to be normal. If you hover the mouse over it does it give you a bulb indicating anything? It might be of no importance but I thought it might be of some value.
Thx for trying to repdroduce Peter. They gray variable means the variable isn't used in any code execution path. This stands apart from the problem that R# says the variable is always false. Of course it can become true and I verified it with the debugger.
At first a though I was wrong because R# made the correct conlusions until now. However, here it seems to make the worng analysis. Can anyone of the team tell whats going on?
Tom, you might be on to something. When I tested your code at home last night that was only against VS.Net 2008 which is all I have installed. At home I'm using 4.0.819.19 which is the official release that I bought from RS.
Here at work I'm using what was the last tested "Works here" nightly build, version 4.1.928.1. I copied and pasted the code snippet I posted last night into console projects in both 2005 and 2008. Yup, I now get the same problem as you.
RS team: Could something have got broken between 4.0.819.19 and 4.1.928.1?