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,
  )>()
  """
)

@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
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.

1 participant