dotnet/roslyn

Spurious use of unassigned variable error with unimplemented partial

開放

#45,875 建立於 2020年7月10日

 (1 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

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.

貢獻者指南