dotnet/roslyn

Spurious use of unassigned variable error with unimplemented partial

Aperta

#45.875 aperta il 10 lug 2020

 (1 commento) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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.

Guida contributor