( /* two parameters, not a tuple */ (Int, Int) -> Void).self == (( /* one tuple parameter */ (Int, Int)) -> Void).self // BUG, which SE-0110 should have fixed, but still didn't
Plus inlined: -- Adrian Zubarev Sent with Airmail Am 7. Juni 2017 um 13:53:08, Gwendal Roué (gwendal.r...@gmail.com) schrieb: func sum1(_ lhs: Int, _ rhs: Int) -> Int { return lhs + rhs } func sum2(lhs: Int, rhs: Int) -> Int { return lhs + rhs } func sum3(tuple: (Int, Int)) -> Int { return tuple.0 + tuple.1 } func sum4(tuple: (lhs: Int, rhs: Int)) -> Int { return tuple.lhs + tuple.rhs } // two arguments func f1(_ closure: (Int, Int) -> Int) { closure(1, 2) } Bug abuse: f1 { tuple in tuple.0 + tuple.1 } f1 { (tuple) in tuple.0 + tuple.1 } f1(sum3) f1(sum4) `f2` is no different from `f1`. Bugs, which should be fixed by `((lhs, rhs)) in`: // one tuple argument func f3(_ closure: ((Int, Int)) -> Int) { closure((1, 2)) } f3 { lhs, rhs in lhs + rhs } f3 { (lhs, rhs) in lhs + rhs } Not possible because ultimately the closures have different types. f3(+) f3(sum1) f3(sum2) Bugs, which should be fixed by `((lhs, rhs)) in`: // one keyed tuple argument func f4(_ closure: ((a: Int, b: Int)) -> Int) { closure((a: 1, b: 2)) } f4 { lhs, rhs in lhs + rhs } f4 { (lhs, rhs) in lhs + rhs } Not possible because ultimately the closures have different types. f4(+) f4(sum1) f4(sum2) Not sure, but I assume this shouldn’t be possible because tuple labels are part of the type and it’s a mismatch like `(lhs: Int, rhs: Int).Type != (a: Int, b: Int).Type`, therefore closures should be of different types as well. f4(sum4)
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution