dotnet/roslyn

"Unassigned local" error for reference to "out var" in lambda with error parameter

Open

#17.225 geöffnet am 17. Feb. 2017

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Repository-Metriken

Stars
 (20.414 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Reports CS0165 for z > 0:

using System;
class C
{
    static void Main()
    {
        G((x, y) => y > 0 && F(out var z) && z > 0);
    }
    static bool F(out int i)
    {
        i = 0;
        return true;
    }
    static void G(Func<int, bool> f, object o) { }
    static void G(Func<int, bool> f, object x, object y) { }
}
(6,9): error CS1501: No overload for method 'G' takes 1 arguments
(6,46): error CS0165: Use of unassigned local variable 'z'

Contributor Guide