Open
Description
Reproduction
Both forms compile without issue:
func mapWithoutTuple<each Input, each Output>(
_ input: (repeat each Input),
_ transform: repeat (each Input) -> each Output
) -> (repeat each Output) {
(repeat (each transform)(each input))
}
func mapWithTuple<each Input, each Output>(
_ input: (repeat each Input),
_ transform: (repeat (each Input) -> each Output) // The difference is only these outer parentheses.
) -> (repeat each Output) {
(repeat (each transform)(each input))
}
The first form is usable.
#expect(
// Explicit "\Int.self" is required here. Maybe a different bug?
mapWithoutTuple(0, \Int.self) as Int == 0
)
#expect(
mapWithoutTuple((0, 1), \.self, \.self) == (0, 1)
)
The second form is not:
_ = mapWithTuple(0, \Int.self)
_ = mapWithTuple((0, 1), (\.self, \.self))
This results in various errors.
Expected behavior
While splatting would be ideal, where parameters being tuples, or not, didn't matter, we should at least be able to write overloads that use either form. And if a form compiles, it should be usable.
Environment
swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-macosx14.0
Additional Information
This is not a problem with only one parameter pack.
func forEach<each Input, Error>(
_ input: (repeat each Input),
_ body: (repeat (each Input) throws(Error) -> Void)
) throws(Error) {
repeat try (each body)(each input)
}
var value = 0
func add(_ summand: Int) { value += summand }
forEach((1, 2), (add, add))
#expect(value == 3) // ✅
Metadata
Metadata
Assignees
Labels
A deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfFeature: expressionsFeature: generic declarations and typesFeature → generics: Parameter packsFeature: tuplesArea → compiler: Semantic analysisFeature: type inferenceBug: Unexpected error