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
Swift should properly distinguish between single-tuple and multiple-argument function types.
But it isn't, as demonstrated below.
The following is the behavior of swift-DEVELOPMENT-SNAPSHOT-2017-06-05-a-osx (-swift-version 4):
func f(_ a: Int, _ b: Int) { print("\(a), \(b)") }
func g(_ tuple: (Int, Int)) { print("\(tuple)") }
f(1, 2) // 1, 2
g((1, 2)) // (1, 2)
// Working as expected.
// But (pay close attention):
var (fCopy, gCopy) = (f, g)
fCopy(1, 2) // 1, 2
gCopy((1, 2)) // (1, 2)
swap(&fCopy, &gCopy)
fCopy(1, 2) // (1, 2)
gCopy((1, 2)) // 1, 2
// I would not expect that call to swap to compile,
// since the type parameter of swap<T> can't be both
// (Int, Int) -> () and
// ((Int, Int)) -> ().
// And also note the last two lines, where fCopy is
// actually calling g, printing its two args as a
// tuple, and gCopy actually calling f, printing its
// single tuple as two separate args.
Additional Detail from JIRA
md5: 313b1547b8d0b52fa35fdf2b6e23d77c
Issue Description:
Swift should properly distinguish between single-tuple and multiple-argument function types.
But it isn't, as demonstrated below.
The following is the behavior of swift-DEVELOPMENT-SNAPSHOT-2017-06-05-a-osx (-swift-version 4):
(Reported as requested by Mark Lacey here:
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170605/037013.html
)
The text was updated successfully, but these errors were encountered: