@@ -337,3 +337,30 @@ var optionalTuple3: (UInt64, Int)? = (bignum, 1) // expected-error {{cannot conv
337337optionalTuple = ( bignum, 1 ) // expected-error {{cannot assign value of type '(Int64, Int)' to type '(Int, Int)'}}
338338// Optional to Optional
339339optionalTuple = optionalTuple2 // expected-error {{cannot assign value of type '(Int64, Int)?' to type '(Int, Int)?'}}
340+
341+ func testTupleLabelMismatchFuncConversion( fn1: @escaping ( ( x: Int , y: Int ) ) -> Void ,
342+ fn2: @escaping ( ) -> ( x: Int , Int ) ) {
343+ // Warn on mismatches
344+ let _: ( ( a: Int , b: Int ) ) -> Void = fn1 // expected-warning {{tuple conversion from '(a: Int, b: Int)' to '(x: Int, y: Int)' mismatches labels}}
345+ let _: ( ( x: Int , b: Int ) ) -> Void = fn1 // expected-warning {{tuple conversion from '(x: Int, b: Int)' to '(x: Int, y: Int)' mismatches labels}}
346+
347+ let _: ( ) -> ( y: Int , Int ) = fn2 // expected-warning {{tuple conversion from '(x: Int, Int)' to '(y: Int, Int)' mismatches labels}}
348+ let _: ( ) -> ( y: Int , k: Int ) = fn2 // expected-warning {{tuple conversion from '(x: Int, Int)' to '(y: Int, k: Int)' mismatches labels}}
349+
350+ // Attempting to shuffle has always been illegal here
351+ let _: ( ) -> ( y: Int , x: Int ) = fn2 // expected-error {{cannot convert value of type '() -> (x: Int, Int)' to specified type '() -> (y: Int, x: Int)'}}
352+
353+ // Losing labels is okay though.
354+ let _: ( ) -> ( Int , Int ) = fn2
355+
356+ // Gaining labels also okay.
357+ let _: ( ( x: Int , Int ) ) -> Void = fn1
358+ let _: ( ) -> ( x: Int , y: Int ) = fn2
359+ let _: ( ) -> ( Int , y: Int ) = fn2
360+ }
361+
362+ func testTupleLabelMismatchKeyPath( ) {
363+ // Very Cursed.
364+ let _: KeyPath < ( x: Int , y: Int ) , Int > = \( a: Int, b: Int) . x
365+ // expected-warning@-1 {{tuple conversion from '(a: Int, b: Int)' to '(x: Int, y: Int)' mismatches labels}}
366+ }
0 commit comments