You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-2216 Confusing behavior related to closure types and tuples
Issue Description:
Demo:
structFoo<T> {
letv: Tinit(_v: T) { self.v = v }
}
typealiasBar = Foo<(Int, Int)>
structBaz {
letv: (Int, Int)
init(_v: (Int, Int)) { self.v = v }
}
// Study the above and this:// (I'm not counting argument list parens here):letf = Foo(1, 2) // Accepts ZERO OR MORE parens around 1, 2.letb = Bar(1, 2) // Accepts ONLY ZERO parens around 1, 2.letc = Baz((1, 2)) // Accepts ONE OR MORE parens around 1, 2.// You can verify that the rules above are correct by adding and// removing parens.// Evidently, Foo<(Int, Int)>, Bar and Baz are different (in that// their initializers can not be used in the same way).// But why/how?
The text was updated successfully, but these errors were encountered:
Here's another related example (same as in the radar):
typealias PairOfInts = (Int, Int)
typealias OptionalPairOfIntsA = Optional<(Int, Int)>
typealias OptionalPairOfIntsB = Optional<PairOfInts>
let p = (1, 2)
let a3 = OptionalPairOfIntsA(p) // OK
let b3 = OptionalPairOfIntsB(p) // OK
let a1 = OptionalPairOfIntsA(1, 2) // OK
let b1 = OptionalPairOfIntsB(1, 2) // Error
let a2 = OptionalPairOfIntsA((1, 2)) // Error
let b2 = OptionalPairOfIntsB((1, 2)) // OK
Additional Detail from JIRA
md5: a64b7a283ff1552980ff726c03db02d6
relates to:
Issue Description:
Demo:
The text was updated successfully, but these errors were encountered: