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

Implicitly-typed lambda parameters have RefKind.None #65350

Merged
merged 3 commits into from
Nov 16, 2022
Merged

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Nov 11, 2022

Fixes #64985

The parameters of an anonymous function in the form of a lambda_expression can be explicitly or implicitly typed. In an explicitly typed parameter list, the type of each parameter is explicitly stated. In an implicitly typed parameter list, the types of the parameters are inferred from the context in which the anonymous function occurs—specifically, when the anonymous function is converted to a compatible delegate type or expression tree type, that type provides the parameter types (§10.7).

The parameter list of an anonymous function in the form of an anonymous_method_expression is optional. If given, the parameters shall be explicitly typed. If not, the anonymous function is convertible to a delegate with any parameter list not containing out parameters.

@jcouv jcouv marked this pull request as ready for review November 11, 2022 18:13
@jcouv jcouv requested a review from a team as a code owner November 11, 2022 18:13
@333fred
Copy link
Member

333fred commented Nov 11, 2022

I don't agree with the original bug here. Is the syntax illegal? Yes. However, the user's experience is likely to be better if we respect the ref that was written in source, as cascaded errors (such as lambda applicability or ref mismatches) are more likely to be lined up with the ref that the user actually specified. I don't think we should change our behavior here.

@jcouv jcouv marked this pull request as draft November 11, 2022 23:06
@jcouv jcouv marked this pull request as ready for review November 15, 2022 20:26
@jcouv jcouv requested a review from 333fred November 16, 2022 17:56
@@ -15635,7 +15635,7 @@ void M()
Assert.Null(model.GetSymbolInfo(invocations[1]).Symbol);
}

[Fact]
[Fact, WorkItem(64985, "https://github.com/dotnet/roslyn/issues/64985")]
Copy link
Member

@cston cston Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WorkItem(64985, "#64985")

Is this test affected by the change? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@jcouv jcouv enabled auto-merge (squash) November 16, 2022 19:30
@jcouv jcouv merged commit 363912b into dotnet:main Nov 16, 2022
@ghost ghost added this to the Next milestone Nov 16, 2022
@allisonchou allisonchou modified the milestones: Next, 17.5 P2 Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The RefKind of implicitly-typed lambda parameters should always be RefKind.None
4 participants