Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect name ambiguity with discard lambda parameters #61143

Closed
TessenR opened this issue May 5, 2022 · 1 comment · Fixed by #61382
Closed

Incorrect name ambiguity with discard lambda parameters #61143

TessenR opened this issue May 5, 2022 · 1 comment · Fixed by #61382
Assignees
Milestone

Comments

@TessenR
Copy link

TessenR commented May 5, 2022

Version Used:

commit 18305a1f4b82de5092cc8f90573afa5a6d091cf8
Merge: afe689ab1a9 265022a3e73
Author: Manish Vasani <mavasani@microsoft.com>
Date:   Fri Apr 29 09:21:23 2022 -0700

    Merge pull request #60906 from mavasani/FixAllCodeRefactoring_2

    Add FixAll support for code refactorings (approach #2)

Steps to Reproduce:

Compile the following code with preview language version.

class AAttribute : System.Attribute
{
  public AAttribute(string s) { }
}

class C
{
  void M(int _)
  {
    System.Func<string, string, int> a = [A(nameof(_))](_, _) => _;
  }
}

Expected Behavior:
The code compiles. nameof(_) references the parameter int _ since lambda parameters are discards and not actual elements.
Note that _ in the lambda body correctly binds to int _ and doesn't consider discard elements

Actual Behavior:
Incorrect and strangely worded error is reported:
error CS0229: Ambiguity between 'string' and 'string'

Notes:
Note that this is also a breaking change as the same code compiles with C# 10. It's a small one and in line with other breaking changes caused by parameter scope changes, but given that here it doesn't bring any new functionality it seems avoidable.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 5, 2022
@jcouv jcouv self-assigned this May 18, 2022
@jcouv jcouv added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels May 18, 2022
@jcouv jcouv added this to the 17.3 milestone May 18, 2022
@jcouv
Copy link
Member

jcouv commented May 19, 2022

Good catch. Fixed in 17.3

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

Successfully merging a pull request may close this issue.

2 participants