Skip to content

EnC: Updating lambda parameters to discards breaks EnC #48635

@tmat

Description

@tmat

Version Used:

Steps to Reproduce:

F5 and update:

class Program
{
    static void Main(string[] args)
    {
        var x = new Func<int, int, int>((a, b) => a + b + 1);
        Console.Write(x(1, 2)); // breakpoint here
    }
}

to

class Program
{
    static void Main(string[] args)
    {
        var x = new Func<int, int, int>((_, _) => 10);
        Console.Write(x(1, 2));
    }
}

Expected Behavior:

The lambda body is matched to the previous one and is updated to return 10. Program prints 10.

Actual Behavior:

The lambdas are not matched, the program prints 2.

See https://github.com/dotnet/csharplang/blob/master/proposals/csharp-9.0/lambda-discard-parameters.md for all forms of discard lambda parameters.

It should also be possible to update discard to named parameter and to change parameter names.

The CLR likely does not support changing IL method parameter names - but we could just ruse the previous names since the method implementing the lambda body is generated and the parameter names do not matter (other than for reflection).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions