Skip to content

Do not reuse BlockSyntax if there are attributes#62153

Merged
AlekseyTs merged 2 commits intodotnet:mainfrom
AlekseyTs:Issue62126
Jun 28, 2022
Merged

Do not reuse BlockSyntax if there are attributes#62153
AlekseyTs merged 2 commits intodotnet:mainfrom
AlekseyTs:Issue62126

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

Fixes #62126.

@AlekseyTs AlekseyTs requested a review from a team as a code owner June 27, 2022 14:49
// Check again for incremental re-use, since ParseBlock is called from a bunch of places
// other than ParseStatementCore()
if (this.IsIncrementalAndFactoryContextMatches && this.CurrentNodeKind == SyntaxKind.Block)
if (this.IsIncrementalAndFactoryContextMatches && this.CurrentNodeKind == SyntaxKind.Block && attributes.Count == 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. attributes are allowed on all statements. are tehre other incremental reuse locations where this causes a problem?
  2. what was the actual issue here that caused a problem?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

attributes are allowed on all statements. are tehre other incremental reuse locations where this causes a problem?

Sure but, apparently, we decided to not implement proper reuse of statements with attributes, see canReuseStatement helper in ParseStatementCore.

what was the actual issue here that caused a problem?

We were reusing a node and dropping the attributes from the new text.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, i see. this might be worth a comment. I also misread what the logic was. I thought it wsa checking the block for attributes, not that attributes had been passed in. Maybe something like "Also, if our caller produced any attributes, we don't want to reuse an existing block syntax directly as we don't want to lose those attributes).

Sure but, apparently, we decided to not implement proper reuse of statements with attributes, see canReuseStatement helper in ParseStatementCore.

That's perfect. That validation is what i was concerned about. e.g. that we weren't missing some other case.

@jcouv jcouv self-assigned this Jun 28, 2022
Copy link
Copy Markdown
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 1)

@AlekseyTs AlekseyTs enabled auto-merge (squash) June 28, 2022 18:45
@AlekseyTs AlekseyTs merged commit 0783ac6 into dotnet:main Jun 28, 2022
@ghost ghost added this to the Next milestone Jun 28, 2022
@allisonchou allisonchou modified the milestones: Next, 17.4 P1 Jul 26, 2022
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.

It seems like a syntax parser bug when combined switch statement and a wrong open square bracket [ token

5 participants