Skip to content

Closures containing parameter packs #70747

@NoahKamara

Description

@NoahKamara

Description

Callbacks that take a parameter pack can not be stored

I am trying to achieve something similar to this but with parameter packs

struct Call<T,J> {
    var callback: (T,J) -> String
    
    init(callback: @escaping (T,J) -> String) {
        self.callback = callback
    }
}

Reproduction

struct PackCall<each T> {
    let callback: (repeat each T) -> Void
    
    init(callback: @escaping (repeat each T) -> Void) {
        self.callback = callback // X - Type of expression is ambiguous without a type annotation
    }
}

Expected behavior

it should work similar to the code in the description

Environment

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions