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.

贡献者指南