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

Fix parsing regression on switch case expression that is parenthesized unary expression #32166

Merged
merged 6 commits into from
Jan 4, 2019

Conversation

gafter
Copy link
Member

@gafter gafter commented Jan 4, 2019

Fixes #32161

@gafter gafter added this to the 16.0.P2 milestone Jan 4, 2019
@gafter gafter self-assigned this Jan 4, 2019
@gafter gafter requested a review from a team January 4, 2019 19:23
@jcouv jcouv self-assigned this Jan 4, 2019
Copy link
Member

@333fred 333fred left a 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;
}
";
Copy link
Member

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;

Copy link
Member Author

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.

Copy link
Member

@jcouv jcouv left a 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;
Copy link
Member

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.

Copy link
Member Author

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.

@gafter gafter merged commit 80570be into dotnet:master Jan 4, 2019
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.

5 participants