Skip to content

Null dereference warning within local function #38548

@cston

Description

@cston

The compiler generates a warning for y.ToString() in 16.4 but no warning in 16.3.

class Program
{
    static void F(System.Action a) { }

    static void M(string? x)
    {
        string? y = x;
        if (y == null) return;

        F(Local);
        return;

        void Local()
        {
            y.ToString();
        }
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions