dotnet/roslyn

Incorrect IDE0059 in a local function : Unnecessary assignment of a value

オープン

#58,407 opened on 2021/12/18

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

Repository metrics

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

説明

Version Used: dotnet 6.0.100 can also repro on master 9f8250964a72d53efe2d04fc0b2b07a48f04a45c via SharpLab (main Roslyn branch)

Steps to Reproduce:

public class C {
    public int M() {
        int i = 0;
        int Recurse()
        {
            if(i > 10) return i;
            i += 1;
            var a = Recurse();
            i += 1;
            var b = Recurse();
            i += 1;  // <<<<<<<<<<< IDE0059 ON THIS LINE
            return a + b;
        }
        return Recurse();
    }
}

Expected Behavior: No IDE0059 Actual Behavior: IDE0059 suggesting the line should be removed. Calling the function before removing the line returns 253 Calling the function after removing the line returns 198

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