dotnet/roslyn

"Redundant assignment" analysis does not consider recursive code path

オープン

#47,655 opened on 2020/09/12

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-IDEBughelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used: VS 2019 16.7.3

Steps to Reproduce:

  1. Create new .NET Core console app.
  2. 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.

コントリビューターガイド