Skip to content

Trailing comma not allowed in generic argument lists despite SE-0439 #81474

@calda

Description

@calda

Description

Trailing commas are supported in some of the following generic argument lists, but not all of them:

struct Foo<
  T1,
  T2,
  T3, // allowed
> { }

typealias Bar<
  T1,
  T2, // allowed
> = Foo<
  T1,
  T2,
  Bool, // trailing comma not allowed here
>

let foo: Foo<
  String,
  Int,
  Bool, // trailing comma not allowed here
>

func bar() -> Foo<
  String,
  Int,
  Bool, // trailing comma not allowed here
> {
  Foo()
}

I would expect trailing commas to be supported in all of these places given SE-0439.

Reproduction

Run the above code using a Swift 6.1 compiler, e.g. https://swiftfiddle.com/w2lk6nc4bvar7fwiwonknrlq6a

Expected behavior

The code should compile, but doesn't.

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 itselfgenericsFeature: generic declarations and typesparserArea → compiler: The legacy C++ parserswift 6.2unexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions