Generic struct using type pack can't store closure using same type pack in property

struct Foo<each T> {
    let foo: (repeat each T) -> Void

    init(
        fn: @escaping (repeat each T) -> Void
    ) {
        self.foo = fn
    }
}

Compiler respond the following message with Xcode 15.0 beta 8 (15A5229m) and swift-DEVELOPMENT-SNAPSHOT-2023-09-04-a toolchain

error: type of expression is ambiguous without a type annotation
        self.foo = fn
        ~~~~~~~~~^~~~

Should this be possible or is it not supported yet ?

Can you file an issue? @xedin This looks like matchFunctionTypes() doesn't handle pack expansions correctly:

    (considering: repeat each T subtype $T3 @ locator@0x121809180 [Assign@q.swift:7:18 → function argument]
      (simplification result:
        (failed constraint each T same-shape $T2 @ locator@0x121809258 [Assign@q.swift:7:18 → function argument → pack shape])
        (removed constraint: repeat each T subtype $T3 @ locator@0x121809180 [Assign@q.swift:7:18 → function argument])
        (failed constraint repeat each T subtype $T3 @ locator@0x121809180 [Assign@q.swift:7:18 → function argument])
      )
1 Like

Issue here : #68369

2 Likes