Hi! I'm seeing some crashes and compiler failures from passing a tuple of only one value to an argument expecting a parameter pack tuple. Passing multiple values in the tuple fixes the compiler failures. I've tested this code on the three latest Swift versions:
Apple Swift version 5.9.2-dev (LLVM 2b42c5ce063a374, Swift 9067148bc9c9a72)
Apple Swift version 5.10-dev (LLVM 551823b7474ea05, Swift 3e816f55ab4b4d4)
Apple Swift version 5.11-dev (LLVM 79aab1b6aed58d0, Swift fd9726839309a33)
My first example fails to compile on all three versions:
struct Repeater<each Element> {
private let element: (repeat () -> each Element)
init(
_ element: (repeat () -> each Element)
) {
self.element = element
}
}
let r = Repeater(
({ 0 })
)
That first example fails with the same error on 5.9.2 and 5.10:
Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 578.
That first example fails on 5.11 with a different failure:
let r = Repeater(
({ 0 }) // Cannot convert value of type '_' to expected argument type '(_: () -> _)'
)
My second example fails only for 5.11:
struct Repeater<each Element> {
init(
_ element: (repeat () -> each Element)
) {
}
}
let r = Repeater(
({ 0 })
)
That second example fails on 5.11 with the same failure from the first example:
My third example compiles on all three versions:
struct Repeater<each Element> {
private let element: (repeat () -> each Element)
init(
_ element: (repeat () -> each Element)
) {
self.element = element
}
}
let r = Repeater(
({ 0 }, { 0 })
)
Any ideas why passing multiple values in my tuple is compiling… but only passing one fails? And why passing only one value compiles when the parameter pack is not saved as an instance variable?
Description
No response
Reproduction
https://gist.github.com/vanvoorden/ff2ab196296646956178c70dc7d9a1fd
Hi! I'm seeing some crashes and compiler failures from passing a tuple of only one value to an argument expecting a parameter pack tuple. Passing multiple values in the tuple fixes the compiler failures. I've tested this code on the three latest Swift versions:
Apple Swift version 5.9.2-dev (LLVM 2b42c5ce063a374, Swift 9067148bc9c9a72)
Apple Swift version 5.10-dev (LLVM 551823b7474ea05, Swift 3e816f55ab4b4d4)
Apple Swift version 5.11-dev (LLVM 79aab1b6aed58d0, Swift fd9726839309a33)
My first example fails to compile on all three versions:
That first example fails with the same error on
5.9.2
and5.10
:That first example fails on
5.11
with a different failure:My second example fails only for
5.11
:That second example fails on
5.11
with the same failure from the first example:My third example compiles on all three versions:
Any ideas why passing multiple values in my tuple is compiling… but only passing one fails? And why passing only one value compiles when the parameter pack is not saved as an instance variable?
Stack dump
Expected behavior
no compiler crashes or errors
Environment
Apple Swift version 5.9.2-dev (LLVM 2b42c5ce063a374, Swift 9067148bc9c9a72)
Apple Swift version 5.10-dev (LLVM 551823b7474ea05, Swift 3e816f55ab4b4d4)
Apple Swift version 5.11-dev (LLVM 79aab1b6aed58d0, Swift fd9726839309a33)
Additional information
No response