dotnet/roslyn

Spurious use of unassigned variable error with unimplemented partial

オープン

#45,875 opened on 2020/07/10

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

Repository metrics

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

説明

public partial class C {
    public partial string M1(string dummyParam, out bool i); // error CS8795: Partial method 'C.M1(string, out bool)' must have an implementation part because it has accessibility modifiers.
    
    public void M2(C c)
    {
        c.M1(null, out bool i);
        _ = i.ToString(); // error CS0165: Use of unassigned local variable 'i'
    }
}

Since this partial method must have an implementation (and we already error on it), we could suppress the error on the use of the unassigned variable.

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