Skip to content

Inferred type not working for yield return in local function #30235

@Neme12

Description

@Neme12
using System.Collections.Generic;

class C
{
    IEnumerable<int> M1()
    {
        yield return foo; // correctly generates int
    }

    void M2()
    {
        IEnumerable<int> F()
        {
            yield return foo; // generates object
        }
    }
}

If I choose to generate a field in M1, its type will be int. If I do the same inside the local function, the type of the field will be object, which is wrong.

Metadata

Metadata

Assignees

Labels

Area-IDEBugResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions