> On Nov 11, 2016, at 1:37 PM, Nevin Brackett-Rozinsky via swift-evolution 
> <[email protected]> wrote:
> I’ll mention this here since it’s related to tuples and optionals. Starting 
> with this setup:
> 
> var x, y: Int?
> func f() -> (Int, Int) { return (0, 1) }
> 
> This fails to compile:
> 
> (x, y) = f()  // Error: Cannot express tuple conversion '(Int, Int)' to 
> '(Int?, Int?)'
> 
> But this works fine:
> 
> func g() -> Int { return 2 }
> (x, y) = (g(), g())
> 
> What is going on, why does the first one fail, and is this a bug or does it 
> need a proposal to fix?

It's a bug.  The error message is actually subtly telling you the problem: the 
type-checker literally can't express the opaque tuple conversion in the AST; 
when it's a raw tuple expression, it can push the element conversions into the 
element expressions, but it can't do that with an opaque tuple.  It's a silly 
restriction because of an unfortunate representational decision.

John.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to