rxwei
(Richard Wei)
1
From SE-0213 it seems like T(literal) should call into the corresponding literal initializer for any literal (integer, float, boolean, string, and array), but it's currently not the case for array literals. Is this a bug?
protocol P {}
extension Int: P {}
struct Foo: ExpressibleByArrayLiteral {
init(arrayLiteral: Int...) {
print("init(arrayLiteral:) is called")
}
init<T: P>(_: [T]) {
print("init(_:) is called")
}
}
_ = Foo([1, 2])
Actual result:
init(_:) is called
Expected result:
init(arrayLiteral:) is called
3 Likes
Nevin
2
I observe the same thing for dictionary literals as well.
xwu
(Xiaodi Wu)
3
Sure seems like a bug to me!