Skip to content

[5.9] Fix 5 parser bugs #1725

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

Merged

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 2, 2023

  1. A round-trip failure for unexpected modifiers in a tuple type
func test(a: (borrowing F o))
  1. A round-trip failure for modifiers in front of an editor placeholder in declaration position
struct a {
  public<#declaration#>
}
  1. A precondition failure when the primary associated type clause of a protocol is empty
protocol X<> {}
  1. It also uncovered an issue where we weren’t able to retrieve the trivia pieces of a token after it had been modified using with because after the modification the token was a parsedToken that no longer resided in a ParsingSyntaxArena. The fix is to search through an arena’s childRefs to find the ParsingSyntaxArena that created it. @rintaro can you review this change?
  2. It uncovered that we were making assumptions about the presence of tokens in ParseDiagnosticGenerator, mostly that tokens in UnexpectedNodesSyntax are present. While this assumption is valid for trees generated by SwiftParser, it doesn’t need to hold for manually generated trees. A couple of minor adjustments to filter for only present tokens fixes this.

@ahoppen ahoppen requested a review from bnbarham June 2, 2023 19:21
@ahoppen
Copy link
Member Author

ahoppen commented Jun 2, 2023

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge June 2, 2023 21:41
ahoppen added 2 commits June 2, 2023 15:22
This uncovered two round-trip parsing failures which I’m fixing in this commit.

rdar://109783066
Just make sure that we don’t crash the diagnostic generator with the mutated test cases.
@ahoppen ahoppen force-pushed the ahoppen/5.9/flip-token-presence branch from b872aec to 13deb8d Compare June 2, 2023 22:23
@ahoppen
Copy link
Member Author

ahoppen commented Jun 2, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 2, 2023

@swift-ci Please test Windows

@ahoppen ahoppen changed the title Fix 5 parser bugs [5.9] Fix 5 parser bugs Jun 3, 2023
@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2023

@swift-ci Please test Linux

@ahoppen ahoppen force-pushed the ahoppen/5.9/flip-token-presence branch from 13deb8d to 8b8912c Compare June 5, 2023 00:44
@ahoppen
Copy link
Member Author

ahoppen commented Jun 5, 2023

@swift-ci Please test

This uncovered a couple of implicit assumptions, mostly around the fact that tokens insided `UnexpectedNodesSyntax` are present, which isn’t true in general for manually generated trees.

It also uncovered an issue where we weren’t able to retrieve the trivia pieces of a token after it had been modified using `with` because after the modification the token was a `parsedToken` that no longer resided in a `ParsingSyntaxArena`.
@ahoppen ahoppen force-pushed the ahoppen/5.9/flip-token-presence branch from 8b8912c to 72fc098 Compare June 6, 2023 21:37
@ahoppen
Copy link
Member Author

ahoppen commented Jun 6, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit d615380 into swiftlang:release/5.9 Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants