-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Improve generic type argument list error recovery #69734
Improve generic type argument list error recovery #69734
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 9)
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to see examples of all of the above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there tests for each of these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some of those might be missing some tests, will make another pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment still applies. :)
src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharpTest/AddUsing/AddUsingTestsWithAddImportDiagnosticProvider.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/MemberDeclarationParsingTests.cs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signing off, with small nit requests.
@dotnet/roslyn-compiler for another set of eyes. thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 27)
@333fred for the second review here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: