-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Trailing comma not allowed in @available annotation despite SE-0439 #81475
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
Comments
Issue also applies to any built-in attribute with parens, like @backDeployed(
before: iOS 17 // trailing comma not allowed
)
public func foo() {}
@freestanding(
declaration,
names: named(CodingKeys) // trailing comma not allowed
)
macro FreestandingMacro() = #externalMacro(module: "Macros", type: "")
@attached(
extension,
names: arbitrary // trailing comma not allowed
)
macro AttachedMacro() = #externalMacro(module: "Macros", type: "") and I suspect also all of the underscored built-in attributes, e.g.: @_originallyDefinedIn(
module: "Foo",
macOS 10.0 // trailing comma not allowed
)
struct Bar {} |
|
This appears to be intentional: #81612 (comment) |
Yeah, there's a bit of underspecification here with the proposal. The bottom line is that we resolved to allow trailing commas where we have purely a comma-separated list within symmetric delimiters and we disallow trailing commas where commas aren't ever permitted within symmetric delimiters (for example: As you've noted, attributes can have custom parsing for their arguments, and during this proposal process no attempt was made to sort out which should or should not be considered purely comma-separated lists that support trailing commas—as this work was never done we have to consider it not part of the approved proposal. |
Description
Trailing commas are unexpectedly not allowed in
@available
annotations, despite annotations being mentioned as a supported use case in SE-0439.Reproduction
Compile the above code using Swift 6.1+: https://swiftfiddle.com/oiaoenmyxbcajdqv4m522kji3q
Expected behavior
It should compile but doesn't
Environment
Swift version 6.2-dev (LLVM a3e32cdaae72f3d, Swift fa86097)
Additional information
No response
The text was updated successfully, but these errors were encountered: