Skip to content

Trailing comma not supported in tuple types or closure types despite SE-0439 #81485

@calda

Description

@calda

Description

In Swift 6.1, trailing commas are unexpectedly not supported in tuple types or closures types, despite being supported in tuple and closure values.

let foo: (
  bar: String,
  quux: String // trailing comma not supported
)

let closure: (
  String,
  String // trailing comma not supported
) -> (
  bar: String,
  quux: String // trailing comma not supported
)


func method(
    bar: String,
    quux: String, // trailing comma supported
) {}

let bar = (
  foo: "foo",
  baaz: "Baaz", // trailing comma supported
)

let closureWithParams = { (
  foo: String,
  bar: String, // trailing comma supported
) in
  print(foo, bar)
}

Reproduction

Compile the above code using Swift 6.1 or later. e.g. https://swiftfiddle.com/727fq4hkxzbcrojuf7e6lpkevu

Expected behavior

The code should compile without errors.

Environment

Swift version 6.2-dev (LLVM a3e32cdaae72f3d, Swift fa86097)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselffunction typesFeature → types: function typesparserArea → compiler: The legacy C++ parserswift 6.2tuple typesFeature → types: Tuple typestypesFeature: typesunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions