BUG : Unused variable

foreach(AsnTrack track in localFreeAsnTracks) track.CheckStatus();

This code gives "Local variable 'track' is never used" warning

3 comments
Comment actions Permalink

Is this reproducable only in particular place of code or you can reproduce
it on a small example?

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

foreach(AsnTrack track in localFreeAsnTracks) track.CheckStatus();

This code gives "Local variable 'track' is never used" warning



0
Comment actions Permalink

Got it. Here is the minimal code example. Note try/catch
and while(true).

public void Run()
{
try
{
while(true)
{
foreach(Item item in collection)
item.Do();
}
}
catch(Exception)
{

}
}

private ItemCollection collection = new ItemCollection();

0
Comment actions Permalink

Hello Boris,
Thank you for the sample! It's a known problem that ReSharper can incorrectly find unused variables, which are actually used, inside "while(true){}" statements. We're planning to fix it in ReSharper 2.0.

Thanks,
Andrew Serebryansky

Got it. Here is the minimal code example. Note try/catch and
while(true).

public void Run()
{
try
{
while(true)
{
foreach(Item item in collection)
item.Do();
}
}
catch(Exception)
{
}
}
private ItemCollection collection = new ItemCollection();


0

Please sign in to leave a comment.