dotnet/roslyn

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

Open

#17.225 aberto em 17 de fev. de 2017

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)C# (4.257 forks)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Métricas do repositório

Stars
 (20.414 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (256 fundiu PRs em 30d)

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'

Guia do colaborador