Skip to content

Conversation

calda
Copy link
Contributor

@calda calda commented Sep 20, 2025

This PR fixes support for trailing commas in tuples within generic arguments.

This currently fails to compile in Swift 6.2 due to being parsed incorrectly. The type lookahead returns false so it confuses the < for a less-than operator.

// error: binary operator '<' cannot be applied to operands of type 'Array<_>.Type' and '(bar: String, baaz: String).Type'
let _ = Array<(
  bar: String,
  baaz: String,
)>()

Corresponding compiler PR: swiftlang/swift#84421

baaz: String,
)>()
""",
substructure: FunctionCallExprSyntax(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to include the substructure: because this test case succeeded as-is without the fix, even though the parsed output was incorrect:

assertParse(
  """
  let _ = Array<(
    bar: String,
    baaz: String,
  )>()
  """
)

Copy link
Member

Choose a reason for hiding this comment

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

Nice, thank you!

@calda calda changed the title Fix support for trailing commas in tuples with generic arguments Fix support for trailing commas in tuples within generic arguments Sep 20, 2025
@rintaro
Copy link
Member

rintaro commented Sep 22, 2025

swiftlang/swift#84421
@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Sep 22, 2025

Regarding the "Format check" failure, please run swift format -ipr . at the top directory of the repo 🙇

@calda calda force-pushed the cal--trailing-comma-in-tuple-in-generic-argument branch from af713f4 to d27e1e3 Compare September 22, 2025 21:22
@calda
Copy link
Contributor Author

calda commented Sep 22, 2025

done, thanks!

@rintaro
Copy link
Member

rintaro commented Sep 22, 2025

swiftlang/swift#84421
@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Sep 22, 2025

swiftlang/swift#84421
@swift-ci Please test

@rintaro
Copy link
Member

rintaro commented Sep 23, 2025

swiftlang/swift#84421
@swift-ci Please test Linux

@rintaro
Copy link
Member

rintaro commented Sep 23, 2025

swiftlang/swift#84421
@swift-ci Please test macOS

@rintaro rintaro merged commit c636838 into swiftlang:main Sep 23, 2025
33 of 34 checks passed
@calda
Copy link
Contributor Author

calda commented Sep 24, 2025

Thanks @rintaro!

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.

2 participants