Skip to content

[6.0] [Macros] Put the insertion location for freestanding macros at the beginning #74927

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

Conversation

DougGregor
Copy link
Member

Explanation: Fixes an ASTScope-construction problem that resulted in incorrect resolution of catch nodes within freestanding macro expansions that involve trailing closures. In the issue, it manifest as an incorrect diagnostic about a thrown error type mismatch, but it could manifest in a number of other bugs with freestanding macro expansions.
Scope: Affects only freestanding macro expansions.
Risk: Low
Testing: Added a new test case
Issue: rdar://130923190
Main branch PR: #74925

…ginning

When building the ASTScope tree, we set the insertion location for the
macro expansion just before the end of the macro use. This is the right
approach for attached macros, because we need to put the entities
after the macro.

However, for freestanding macros, which can have trailing closures,
this location is a problem, because the scope for the macro
expansion ends up inside the scope for the trailing closure. Use the
start location of the freestanding macro instead.

Fixes rdar://130923190.
@DougGregor DougGregor requested a review from a team as a code owner July 3, 2024 04:11
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor enabled auto-merge July 3, 2024 04:26
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor merged commit ef2320c into swiftlang:release/6.0 Jul 3, 2024
5 checks passed
@DougGregor DougGregor deleted the astscope-insertion-loc-freestanding-6.0 branch July 3, 2024 20:18
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.

2 participants