Skip to content

[Macros] Tighten restriction on non-expression macros not having return types #66526

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
merged 3 commits into from
Jun 10, 2023

Conversation

DougGregor
Copy link
Member

There is no reason to special-case Void to permit it. Rather, make this a syntactic rule. Thanks to Alex Hoppen for the suggestion.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

DougGregor commented Jun 10, 2023

Hehehehe. Our standard library does this:

/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/lib/swift/macosx/Swift.swiftmodule/x86_64-apple-macos.swiftinterface:12610:72: error: only a freestanding expression macro can produce a result of type '()'
@freestanding(declaration) public macro error(_ message: Swift.String) -> () = Builtin.ErrorMacro
                                                                       ^  ~~

We'll need to stage in this bit.

Correction: the module interface printer does this, not the standard library itself.

…rn types

There is no reason to special-case `Void` to permit it. Rather, make
this a syntactic rule. Thanks to Alex Hoppen for the suggestion.
…terfaces

This allows us to continue to accept Swift interface files created with
older versions of the Swift 5.9 compiler that emitted a spurious
`-> ()` on non-expression macro declarations.
@DougGregor DougGregor force-pushed the non-expression-macro-no-void branch from ca5cbd2 to f7de3a3 Compare June 10, 2023 06:26
@DougGregor DougGregor requested a review from tshortli as a code owner June 10, 2023 06:26
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 9b9d576 into swiftlang:main Jun 10, 2023
@DougGregor DougGregor deleted the non-expression-macro-no-void branch June 10, 2023 14:49
Comment on lines +2079 to +2080
auto resultType = MD->getResultInterfaceType(); {
auto diag = Ctx.Diags.diagnose(
Copy link
Member

Choose a reason for hiding this comment

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

This looks really odd to me. Why do you open a new brace scope at the same line as

auto resultType = MD->getResultInterfaceType();

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