[swift-users] another issue with tuples

Aaron Bohannon aaron678 at gmail.com
Wed Jul 6 00:48:02 CDT 2016

Yesterday, it was pointed out that a variable name referring to a tuple
cannot be used as a pattern.  I have noticed another sort of inconsistency
in how tuples are treated when they are referenced by name:

func f() -> Int { return 5 }

let t = ("a", f)

let _: (String, () throws -> Int) = t  // type error
let _: (String, () throws -> Int) = (t.0, t.1)  // OK

This situation leads to a different sort of type error; however, the error
seems equally unwarranted.  I can't see any good reason for a well-typed
program to become ill-typed when `(t.0, t.1)` is replaced with `t`
(assuming `t` is a pair).

Should I file a separate bug for the specific example above?

- Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160705/ec830ca3/attachment.html>

More information about the swift-users mailing list