Last active
August 29, 2015 14:10
-
-
Save airspeedswift/bdddbb23c2e941f5e835 to your computer and use it in GitHub Desktop.
Upconverted function returning tuple of optionals corrupts on destructuring return value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func f()->(Int,Int) { | |
return (1,1) | |
} | |
func g(f: ()->(Int?,Int?)) -> (Int,Int) { | |
let (a,b) = f() | |
return (a ?? 0, b ?? 0) | |
} | |
// ()->(Int,Int) is substitutable for | |
// ()->(Int?,Int?) so this compiles | |
let x = g(f) | |
// but results are corrupted | |
println(x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment