Handle unexpected keyword rather than identifier for lambda parameter name#60825
Handle unexpected keyword rather than identifier for lambda parameter name#60825cston merged 7 commits intodotnet:mainfrom
Conversation
| { | ||
| static void Main() | ||
| { | ||
| Action<int> a = int => { }; |
There was a problem hiding this comment.
Consider adding another test for public. Currently the behavior for int (stack exhausting) is different than public (too many syntax errors).
Also consider testing with @int (not too important) #Resolved
There was a problem hiding this comment.
Added a parsing test for a full syntax tree with public.
|
@dotnet/roslyn-compiler, please review, thanks. |
| // x => ... | ||
| // x!! => ... | ||
| var identifier = this.ParseIdentifierToken(); | ||
| var identifier = (this.CurrentToken.Kind != SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken) ? |
There was a problem hiding this comment.
Could you clarify why we need to peek for an => here? It seems like we already scanned and determined that this is a lambda? #Resolved
There was a problem hiding this comment.
The lambda expression may be x => ... or just => ... (missing parameter name).
|
@dotnet/roslyn-compiler, please review, thanks. |
| // x => ... | ||
| // x!! => ... | ||
| var identifier = this.ParseIdentifierToken(); | ||
| var identifier = (this.CurrentToken.Kind != SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken) ? |
There was a problem hiding this comment.
Should we also condition on whether there's a !! token?
Never mind, we're removing that feature. #Closed
| [Theory] | ||
| public void KeywordParameterName_01(LanguageVersion languageVersion) | ||
| { | ||
| string source = "int =>"; |
There was a problem hiding this comment.
Is this only an issue for non-parenthesized lambdas? What if we had (int, int) =>?
There was a problem hiding this comment.
It might also be good to just test (int) => as well.
…ures/semi-auto-props * upstream/main: (266 commits) Pass fallback options (#60803) Rename `CodeStyleHostLanguageServices.cs.cs` to `CodeStyleHostLanguageServices.cs` (#60955) Allow VSMac to access LSP options (#60943) Add configs for 17.3 branch and update main version (#60942) Restore nugetKind config to publish data Remove unnecessary publish data config Remove non-servicing 15.x publish config Let 'arcade' packageFeeds imply all feeds are 'arcade' Remove non-servicing branches from our PublishData Handle unexpected keyword rather than identifier for lambda parameter name (#60825) Correctly return E_NOTIMPL when asked for file code models for non-source Move the resources to top (#60899) Add back deprecated packages to arcade publishing config. Simplify Rename parameter Simplify visibility logic in tagger Simplify visibility logic in tagger Try out some fixes Update StructConstructorTests.cs Use more descriptive variable name ...
…ures/required-members * upstream/main: (156 commits) Pass fallback options (#60803) Rename `CodeStyleHostLanguageServices.cs.cs` to `CodeStyleHostLanguageServices.cs` (#60955) Allow VSMac to access LSP options (#60943) Add configs for 17.3 branch and update main version (#60942) Restore nugetKind config to publish data Remove unnecessary publish data config Remove non-servicing 15.x publish config Let 'arcade' packageFeeds imply all feeds are 'arcade' Remove non-servicing branches from our PublishData Handle unexpected keyword rather than identifier for lambda parameter name (#60825) Correctly return E_NOTIMPL when asked for file code models for non-source Move the resources to top (#60899) Add back deprecated packages to arcade publishing config. Simplify Rename parameter Simplify visibility logic in tagger Simplify visibility logic in tagger Try out some fixes Update StructConstructorTests.cs Use more descriptive variable name ...
…o forbid-new * upstream/features/required-members: (156 commits) Pass fallback options (dotnet#60803) Rename `CodeStyleHostLanguageServices.cs.cs` to `CodeStyleHostLanguageServices.cs` (dotnet#60955) Allow VSMac to access LSP options (dotnet#60943) Add configs for 17.3 branch and update main version (dotnet#60942) Restore nugetKind config to publish data Remove unnecessary publish data config Remove non-servicing 15.x publish config Let 'arcade' packageFeeds imply all feeds are 'arcade' Remove non-servicing branches from our PublishData Handle unexpected keyword rather than identifier for lambda parameter name (dotnet#60825) Correctly return E_NOTIMPL when asked for file code models for non-source Move the resources to top (dotnet#60899) Add back deprecated packages to arcade publishing config. Simplify Rename parameter Simplify visibility logic in tagger Simplify visibility logic in tagger Try out some fixes Update StructConstructorTests.cs Use more descriptive variable name ...
Fixes #60661