Skip to content

Conversation

@DougGregor
Copy link
Member

Eliminate the error message

error: global freestanding macros not yet supported in script mode

by implementing name lookup, type checking, and code emission for freestanding macros. The key problem here is that, in script mode, it is ambiguous whether a use of a freestanding macro is an expression or a declaration. We parse as an expression (as we do within a function body), which then gets wrapped in a top-level code declaration.

Teach various parts of the compiler to look through a top-level code declaration wrapping a macro expansion expression that is for a declaration or code-item macro, e.g., by recording these for global name lookup and treating their expansions as "auxiliary" declarations.

Fixes rdar://109699501.

Eliminate the error message

    error: global freestanding macros not yet supported in script mode

by implementing name lookup, type checking, and code emission for
freestanding macros. The key problem here is that, in script mode,
it is ambiguous whether a use of a freestanding macro is an expression
or a declaration. We parse as an expression (as we do within a
function body), which then gets wrapped in a top-level code
declaration.

Teach various parts of the compiler to look through a top-level code
declaration wrapping a macro expansion expression that is for a
declaration or code-item macro, e.g., by recording these for global
name lookup and treating their expansions as "auxiliary" declarations.

Fixes rdar://109699501.
@DougGregor DougGregor requested a review from a team as a code owner July 4, 2023 17:23
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor merged commit de6b484 into swiftlang:release/5.9 Jul 5, 2023
@DougGregor DougGregor deleted the freestanding-macro-global-scope-in-scripts-5.9 branch July 5, 2023 00:03
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