dotnet/roslyn

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

Open

#17,225 opened on Feb 17, 2017

View on GitHub
 (2 comments) (0 reactions) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Description

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