Xcode 7.1b3 (7B85): [Swift] Tuple 'promotion' is inconsistent

Originator:janoschhildebrand
Number:rdar://23199763 Date Originated:21-Oct-2015
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.1b3 (7B85)
Classification:Other Bug Reproducible:Always
 
Summary:
In some contexts, argument lists are automatically promoted to tuples by the compiler. However this behaviour is inconsistent.

The following example demonstrates this issue:

var array: [(Int, Int)] = []
var int_var = 1
let int_let = 1


// This works
array.append(int_let, int_let)

// "Cannot invoke 'append' with an argument list of type '(Int, Int)'"
array.append(int_let, 1)

// "Cannot invoke 'append' with an argument list of type '(Int, Int)'"
array.append(1, 1)

// "Cannot invoke 'append' with an argument list of type '(Int, Int)'"
array.append(int_var, 1)

// "Cannot invoke 'append' with an argument list of type '(Int, Int)'"
array.append(int_var, int_var)


// These work
array.append((int_let, 1))
array.append((1, 1))
array.append((int_var, 1))
array.append((int_var, int_var))


An Xcode project demonstrating this issue is also attached.

Steps to Reproduce:
Open the attached project and you should see the compiler errors.

Expected Results:
Either no automatic promotion to tuples should occur, meaning

array.append(int_let, int_let)

should also produce an error, or tuple promotion should work consistently for all the given examples, meaning the given program should compile without errors.

Actual Results:
Tuple promotion is inconsistent, working only in one of the provided examples.

Version:
Xcode 7.1b3 (7B85)
Apple Swift version 2.1 (swiftlang-700.1.101.3 clang-700.1.75)
OS X 10.11 (15A284)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!