-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Macros] Disallow expression macro as default argument #68782
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
[Macros] Disallow expression macro as default argument #68782
Conversation
@swift-ci please test |
Can't we fix the behavior (by propagating source location information to the callsite) instead of turning it off? It would be absolutely great to have this working. Holly solved the expansion of magic literals to accurately represent values in the outermost source file. Can we take this a step further and process default arguments as well? |
Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
92afc89
to
35d5b68
Compare
Hi @tevelee, I agree that allowing non-built-in macro as default argument could be an interesting future direction. But as reasoned in the original proposal, we should disable it right now as specified, and go through Swift Evolution process to make sure that developers won't be surprised by when the macros expand:
|
@swift-ci please smoke test |
Thanks for the context, @ApolloZhu! I missed this during the review of the proposal, your PR makes perfect sense now. |
…ault-argument [Macros] Disallow expression macro as default argument
Add error diagnostic when an expression macro is used as the default argument per SE-0382. Using a macro as a sub expression in default argument position is still allowed as expression macros behave the same as built-in magic literals.
rdar://115674594