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 parser regressions of conditional expressions #75075

Merged
merged 6 commits into from
Sep 24, 2024

Conversation

DoctorKrolic
Copy link
Contributor

Fixes: #75074

@DoctorKrolic DoctorKrolic requested a review from a team as a code owner September 12, 2024 11:52
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 12, 2024
@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Sep 12, 2024
@NicholasMoss
Copy link

Thanks for looking into this so quickly.

I've double checked all places our solution breaks and it seems to happen for the from in linq query expression too.

I've added full replication steps onto the original ticket #75074

@DoctorKrolic DoctorKrolic changed the title Fix regression of parsing with expression in conditional expression Fix parser regressions of conditional expressions Sep 12, 2024
@DoctorKrolic
Copy link
Contributor Author

I looked through the list of all contextual keywords and I don't see other keywords, which might be problematic for us. When reviewing please also look through them and point out, if I missed something. Even if the scenario is not a regression, we better add a test or a few for it

@CyrusNajmabadi
Copy link
Member

Do you have tests for await x and await(x) both inside and outside an async context?

Copy link
Member

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:

  • global
  • yield

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test for global qualified name. As of yield, since it is only valid as a yield return and yield break statements, it cannot be a contextual keyword inside an expression. However, this gave me an idea: if we have something like x is X ? yield return 0 ... we can parse it a lot better we we consider x is X? yield as one statement and return 0 ... as another one with missing ; in between. This is actually true for most keywords that start a statement: if, while, for etc. For now I added 2 yield tests with the right shape to just swap the errors and parse result in the future, but when main branch targets 17.13, I'm gnna make a follow-up PR with imrpoved error recovery for such cases

@333fred
Copy link
Member

333fred commented Sep 20, 2024

@DoctorKrolic are you going to be able to address feedback, or should we pick this up the rest of the way?

@DoctorKrolic
Copy link
Contributor Author

@333fred PTAL

@jaredpar jaredpar added this to the 17.12 milestone Sep 24, 2024
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.

@cston for a second review.

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 6)

@jcouv jcouv self-assigned this Sep 24, 2024
@jcouv jcouv merged commit 7b43a18 into dotnet:main Sep 24, 2024
24 checks passed
@dotnet-policy-service dotnet-policy-service bot modified the milestones: 17.12, Next Sep 24, 2024
@jcouv
Copy link
Member

jcouv commented Sep 24, 2024

Thanks @DoctorKrolic !

@DoctorKrolic DoctorKrolic deleted the with-parsing-regression branch September 25, 2024 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
7 participants