swift
232a8d3a - [Macros] Enable freestanding macros at module scope in script mode

Commit
2 years ago
[Macros] Enable freestanding macros at module scope in script mode 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.
Author
Committer
Parents
Loading