Skip to content

Don't insert trailing commas into attribute argument lists#1215

Merged
allevato merged 1 commit into
swiftlang:mainfrom
ayush-that:fix-trailing-comma-in-attributes
Jun 8, 2026
Merged

Don't insert trailing commas into attribute argument lists#1215
allevato merged 1 commit into
swiftlang:mainfrom
ayush-that:fix-trailing-comma-in-attributes

Conversation

@ayush-that

@ayush-that ayush-that commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

fixes #1178.

alwaysUsed inserted a trailing comma into multiline @attached(...) arguments, which the parser rejects (see swiftlang/swift-syntax#3306). macro role and custom attributes are syntactically indistinguishable, so never insert into any attribute's argument list. an existing comma is still managed as configured.

@allevato allevato left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! This seems like a straightforward solution for now vs. trying to hard-code which attributes support this and which don't.

There may be some divergence between what we do here and what tools like SwiftLint might do, to which my answer is still "you shouldn't use multiple linters to check the same rule".

@allevato allevato merged commit 68e501b into swiftlang:main Jun 8, 2026
30 checks passed
Jason-Abbott added a commit to toba/swiftiomatic that referenced this pull request Jun 8, 2026
… don't insert trailing commas into attribute argument lists under multilineTrailingCommaBehavior: alwaysUsed (mirror swiftlang/swift-format#1215); recognize Swift 6.2 'isolated' declaration modifier in SortModifiers' canonical isolation slot alongside 'nonisolated' (mirror realm/SwiftLint#6759); compute NestedCallLayout.columnOffset in grapheme clusters uniformly instead of mixing String.count on tokens with UTF-8 byte length on trivia, fixing column over-count when preceding tokens or trivia contain multi-byte characters (mirror realm/SwiftLint#6747)
@ayush-that ayush-that deleted the fix-trailing-comma-in-attributes branch June 14, 2026 15:45
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.

multilineTrailingCommaBehavior: alwaysUsed breaks macro attributes e.g. @attached(...)

2 participants