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 F1 keywords clashing for !_CSharpKeyword #47516

Merged
6 commits merged into from
Sep 11, 2020
Merged

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Sep 7, 2020

Fixes #46988

@davidwengier Can you review? Also, we should get the docs PR (dotnet/docs#20341) merged first right?

@Youssef1313 Youssef1313 requested a review from a team as a code owner September 7, 2020 21:14
{
text = token.Parent.IsKind(SyntaxKind.LogicalNotExpression)
? Keyword("!")
: Keyword("nullForgiving");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a little like redoing some of the logic the parser is doing for us already, and will fall down if exclamation points are used for something else in future. For example there is a proposal for argument validation that would use it.

To me it makes more sense to simply check if the parent is SuppressNullableWarningExpression and return Keyword("nullForgiving") for that, and let the rest of the code flow as it did before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidwengier I did that in the latest commit but just realized a problem with that approach.
For null forgiving operator, SuppressNullableWarningExpression won't always be the parent.
The parent could be MemberAccessExpression whose parent is SuppressNullableWarningExpression.
So, that will need traversing the tree up to make sure it'll work correctly.

Does it worth doing so?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I believe there are many other cases that aren't handled correctly. For example, the colon in inheritance vs ternary operator.

Do you see a way to refactor the whole thing instead of keeping special-casing more things? probably make it based on semantics instead of syntax?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent could be MemberAccessExpression whose parent is SuppressNullableWarningExpression.

What scenario would have this?

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 looked again in SharpLab and it was just my eyes incorrectly seeing sibling nodes as parent/children 😄 . So this approach should just work.

@davidwengier davidwengier self-assigned this Sep 7, 2020
@davidwengier davidwengier added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Sep 7, 2020
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with the suggestion sam made.

…Service.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
@ghost
Copy link

ghost commented Sep 10, 2020

Hello @davidwengier!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approval

@Youssef1313
Copy link
Member Author

@sharwell @davidwengier Can you re-run the integration tests please?

@davidwengier
Copy link
Contributor

I've restarted the leg than hung, and will monitor if it passes (and then if GitHub can be convinced that it has)

@ghost ghost merged commit 5f0cfa7 into dotnet:master Sep 11, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE auto-merge Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with !_CSharpKeyword
6 participants