Fix parsing of for-loops#76476
Merged
CyrusNajmabadi merged 10 commits intodotnet:mainfrom Dec 17, 2024
Merged
Conversation
Contributor
Author
|
@dotnet/roslyn-compiler @RikkiGibson ptal |
333fred
approved these changes
Dec 17, 2024
RikkiGibson
reviewed
Dec 17, 2024
| @@ -9181,23 +9181,27 @@ private ForStatementSyntax ParseForStatement(SyntaxList<AttributeListSyntax> att | |||
| var (variableDeclaration, initializers) = eatVariableDeclarationOrInitializers(); | |||
|
|
|||
| // Pulled out as we need to track this when parsing incrementors to place skipped tokens. | |||
Member
There was a problem hiding this comment.
It looks like this comment was specific to secondSemicolonToken before, is it still relevant now?
Contributor
Author
There was a problem hiding this comment.
yes/ will move.
RikkiGibson
reviewed
Dec 17, 2024
src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs
Show resolved
Hide resolved
CyrusNajmabadi
commented
Dec 17, 2024
CyrusNajmabadi
commented
Dec 17, 2024
Contributor
Author
|
@RikkiGibson this is ready for another pass. |
RikkiGibson
approved these changes
Dec 17, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #76439
Introduced with #75632. So only in 17.13p2. So fixing this will prevent the regression from making it out.
The core issue here was an incorrect understanding i had with order-of-evaluation and storage of values for args when invoking methods. Specifically, i thought that the following:
Was evaluated effectively as:
But it is not. rather, it is:
In other words, i thought the call to M woudl see the value of 'x' after the call to Z, while it actually evaluates and stores that value prior to the call to Z.
This mattered during parsing as we use that value to store skipped tokens onto. So if we use the value prior to updating, we lose those skipped tokens, leading to an invalid incremental parse.