Improve generic type argument list error recovery#69734
Improve generic type argument list error recovery#69734333fred merged 29 commits intodotnet:mainfrom
Conversation
|
@dotnet/roslyn-compiler for second review. Thanks |
| or SyntaxKind.OpenBraceToken | ||
| or SyntaxKind.CloseBraceToken | ||
| or SyntaxKind.EqualsToken | ||
| or SyntaxKind.EqualsGreaterThanToken; |
There was a problem hiding this comment.
It would be nice to see examples of all of the above.
There was a problem hiding this comment.
Are there tests for each of these cases?
There was a problem hiding this comment.
I think some of those might be missing some tests, will make another pass
There was a problem hiding this comment.
this comment still applies. i want to know why each of those cases are something that would break the argument list.
There was a problem hiding this comment.
comment still applies. :)
src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharpTest/AddUsing/AddUsingTestsWithAddImportDiagnosticProvider.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/SeparatedSyntaxListParsingTests.cs
Outdated
Show resolved
Hide resolved
| case SyntaxKind.OrKeyword: | ||
| case SyntaxKind.AndKeyword: | ||
| case SyntaxKind.NotKeyword: | ||
| return true; |
There was a problem hiding this comment.
can you give an example of where this arises (in a code comment). #Closed
| // Example: IEnumerable<string Method<T>() | ||
| is SyntaxKind.LessThanToken | ||
| // Example: Method<string(argument) | ||
| or SyntaxKind.OpenParenToken |
There was a problem hiding this comment.
i would break these into separate 'if' checks. Different ones warrant different comments. For example, for this, i would mention, this means we'll do a bad job with Method<string (int a, ... where the ( starts a tuple type argument. But that we're ok with taht as we don't want to look that far ahead, and we feel like it's more likely that it's a parameter list.
CyrusNajmabadi
left a comment
There was a problem hiding this comment.
Signing off, with small nit requests.
|
@dotnet/roslyn-compiler for another set of eyes. thanks! |
|
@333fred for the second review here. |
333fred
left a comment
There was a problem hiding this comment.
Mostly this looks good to me. Just a few comments.
| // Example: x is IEnumerable<string or IList<int> | ||
| case SyntaxKind.OrKeyword: | ||
| // Example: x is IEnumerable<string and IDisposable | ||
| case SyntaxKind.AndKeyword: |
There was a problem hiding this comment.
Do we have tests for tuple types where the tuple type name is and or or and the tuple is unterminated?
There was a problem hiding this comment.
I think I'd like to see a few tests with missing tuple end ). For example: IEnumerable<(string Value, string Description Values { get; }
|
Thanks @Rekkonnect! |
* upstream/main: (416 commits) Semantic search (dotnet#71268) Make more static Fix MEF import of IExternalCSharpCopilotCodeAnalysisService to allow null Make static Make private Add comments Add method name to TimeInQueue telemetry (dotnet#72841) switch to frozen Simplify Add test Downstream Use singular helper when creating checksumsw Use singular helper when creating checksumsw Remove ability for a project to change its language Revert "Avoid creating result temp for is-expressions (dotnet#72273)" (dotnet#72827) Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2420199 Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2420199 Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2420199 Localized file check-in by OneLocBuild Task: Build definition ID 327: Build ID 2420199 Improve generic type argument list error recovery (dotnet#69734) ...
Fixes #24642
Fixes #48566
Also improves error recovery in bad tuple type arguments of the form
(a x, b y) c.Some erroneous code cases were also adjusted; the parser now leans more towards parsing generics than comparison expressions, only to improve error recovery.
The parser's logic now is: