Skip to content

A lambda's captured parameter is listed twice in Locals #58

Description

@hexbinoct

Built from source at 293d77f (0.1.17), net10.0, Windows x64. This is about the display class lifting added in 7175609.

A parameter captured by a lambda is listed twice in Locals, once from its own slot and once from the compiler generated environment's copy.

static void Outer(int captured)
{
    var f = () => captured + 1;
    Console.WriteLine(f());   // stop here
}

Locals shows captured twice, with the same value.

For a nested lambda the outer environment's names come back again on top of that, so the deeper the nesting the more repeats.

Expected is one entry per name. When a parameter has been hoisted into a display class, the environment's copy is the live one and the original slot is not updated, so the environment's copy is the one to show.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions