-
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
Fix parsing regression on switch case expression that is parenthesized unary expression #32166
Conversation
…d unary expression. Fixes dotnet#32161
src/Compilers/CSharp/Portable/Parser/LanguageParser_Patterns.cs
Outdated
Show resolved
Hide resolved
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 (commit 1)
case (+2): break; | ||
case (~3): break; | ||
} | ||
"; |
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 other interesting cases? Perhaps:
case (^1): break;
case ((-1)): break;
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 don't think those cases are different in any way that is relevant to the bug or its fix.
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 4)
!(SyntaxFacts.IsBinaryExpression(tk) || SyntaxFacts.IsAssignmentExpressionOperatorToken(tk)); | ||
return isExpression || this.CurrentToken.Kind == SyntaxKind.OpenBraceToken; | ||
return this.IsPossibleExpression(allowBinaryExpressions: false, allowAssignmentExpressions: false) || | ||
this.CurrentToken.Kind == SyntaxKind.OpenBraceToken; |
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.
Thanks! Note: i would personally find it valuable if there was an explanation here (even if brief) as to why neither of these expression forms are allowed. i.e. what hte intuition here is for why this is correct.
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.
These parameters are about whether binary operator tokens should be accepted. We don't want a token such as ==
to be considered to be permitted in this context.
Fixes #32161