Skip to content

spaceAroundParens inserts space for Optional.some in @Test arguments from second test #2525

@AleMaMi

Description

@AleMaMi

SwiftFormat adds space between Optional.some and value if used in @Test arguments (to force type detection in the macro). But it starts happening from second test. Artificial example:

Original code

@Test(arguments: [String?.some("input")])
func first_test(input: String?) {
    #expect(input == "input")
}

@Test(arguments: [String?.some("input")])
func other_test(input: String?) {
    #expect(input == "input")
}

Lint detects an error at line 6
SpaceAroundParens.swift:6:1: error: (spaceAroundParens) Add or remove space around parentheses.

And when format is applied, the result:

@Test(arguments: [String?.some("input")])
func first_test(input: String?) {
    #expect(input == "input")
}

@Test(arguments: [String?.some ("input")])
func other_test(input: String?) {
    #expect(input == "input")
}

It inserts space between some and ("input"), but only for second (and following) tests.

Environment:
SwiftFormat 0.61.1
macOS 26.4.1
swift

swift-driver version: 1.148.6 Apple Swift version 6.3.1 (swiftlang-6.3.1.1.2 clang-2100.0.123.102)
Target: arm64-apple-macosx26.0

Metadata

Metadata

Assignees

Labels

fixed in developbug/feature resolved in the develop branch

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions