dotnet/roslyn
"Redundant assignment" analysis does not consider recursive code path
Ouverte
#47 655 ouverte le 12 sept. 2020
Area-IDEBughelp wanted
Métriques du dépôt
- Stars
- (20 414 étoiles)
- Métriques de merge PR
- (Merge moyen 6j 17h) (256 PRs mergées en 30 j)
Description
Version Used: VS 2019 16.7.3
Steps to Reproduce:
- Create new .NET Core console app.
- Paste the following code.
static void Foo(Exception ex)
{
var indentLevel = 0;
void Bar(Exception e)
{
indentLevel++;
if (indentLevel < 5)
Bar(e);
indentLevel--;
}
Bar(ex);
}
Expected Behavior: No analysis complaints
Actual Behavior:
VS claims that indentLevel-- is a redundant assignment.
This is true for the top level call to Bar but not true for the recursive calls that reference the same indentLevel variable.