-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as not planned
Closed as not planned
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsFeature → expressions: Call expressionsclosuresFeature: closuresFeature: closurescompilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inferenceunexpected errorBug: Unexpected errorBug: Unexpected error
Description
Description
When trying to use a function that accepts a parameter pack and a closure as its arguments, I'm getting the "extra arguments" error.
Reproduction
func test<each T>(_ pack: repeat each T, callback: (repeat each T) -> Void) {}
test(1, 2, 3, callback: { _ in })
The error:
error: extra arguments at positions #2, #3 in call
test(1, 2, 3, callback: { _ in })
^
note: 'test(_:callback:)' declared here
func test<each T>(_ pack: repeat each T, callback: (repeat each T) -> Void) {
^
Expected behavior
The above code should compile because 1, 2, 3
is a valid parameter pack, and should be used as a first argument to the function.
Environment
Swift version 5.11-dev (LLVM d50917983d84235, Swift 98e65d0)
Additional information
The following code, with (repeat each T)
replaced with (Int)
in the type of the closure, works fine:
func test<each T>(_ pack: repeat each T, callback: (Int) -> Void) {}
test(1, 2, 3, callback: { _ in })
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsFeature → expressions: Call expressionsclosuresFeature: closuresFeature: closurescompilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer errorparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistype inferenceFeature: type inferenceFeature: type inferenceunexpected errorBug: Unexpected errorBug: Unexpected error