[Macros] Allow keywords after #
in freestanding macro expansions
#66643
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See swiftlang/swift-syntax#1778
Allow keywords after
#
in freestanding macro expansionsThere is no reason why we shouldn’t allow keywords here.
I also thought about allowing keywords after
@
but things become tricky here for two reasons:@
, which could start with a keyword itself (e.g.any
). If we want to keep the parser logic to parse a type after@
(which I think we should), then it becomes unclear what@any T
should parse as.@
and the type name. This makes it very hard for recovery to tell whether@ struct
refers to an attribute with namestruct
or if the user forgot to write the attribute name after@
.Since almost all keywords are lowercase and attached member macros are usually spelled with an uppercase name, there are a lot fewer chances for clashes here, so I don’t think it’s worth allowing keywords after
@
.#66444
rdar://110472060