|
1 | 1 | // RUN: %target-typecheck-verify-swift -swift-version 5 |
2 | 2 |
|
3 | | - func consume<T>(_ x: T) {} // Suppress unused variable warnings |
| 3 | +func consume<T>(_ x: T) {} // Suppress unused variable warnings |
4 | 4 |
|
5 | | - func shuffle_through_initialization() { |
6 | | - let a = (x: 1, y: 2) |
7 | | - let b: (y: Int, x: Int) |
8 | | - b = a // expected-warning {{expression shuffles the elements of this tuple}} |
9 | | - consume(b) |
10 | | - } |
| 5 | +func shuffle_through_initialization() { |
| 6 | + let a = (x: 1, y: 2) |
| 7 | + let b: (y: Int, x: Int) |
| 8 | + b = a // expected-warning {{expression shuffles the elements of this tuple}} |
| 9 | + consume(b) |
| 10 | +} |
11 | 11 |
|
12 | | - func shuffle_through_destructuring() { |
13 | | - let a = (x: 1, y: 2) |
14 | | - let (y: b, x: c) = a // expected-warning {{expression shuffles the elements of this tuple}} |
15 | | - consume((b, c)) |
16 | | - } |
| 12 | +func shuffle_through_destructuring() { |
| 13 | + let a = (x: 1, y: 2) |
| 14 | + let (y: b, x: c) = a // expected-warning {{expression shuffles the elements of this tuple}} |
| 15 | + consume((b, c)) |
| 16 | +} |
17 | 17 |
|
18 | | - func shuffle_through_call() { |
19 | | - func foo(_ : (x: Int, y: Int)) {} |
20 | | - foo((y: 5, x: 10)) // expected-warning {{expression shuffles the elements of this tuple}} |
21 | | - } |
| 18 | +func shuffle_through_call() { |
| 19 | + func foo(_ : (x: Int, y: Int)) {} |
| 20 | + foo((y: 5, x: 10)) // expected-warning {{expression shuffles the elements of this tuple}} |
| 21 | +} |
22 | 22 |
|
23 | | - func shuffle_through_cast() { |
24 | | - let x = ((a: Int(), b: Int()) as (b: Int, a: Int)).0 // expected-warning {{expression shuffles the elements of this tuple}} |
| 23 | +func shuffle_through_cast() { |
| 24 | + let x = ((a: Int(), b: Int()) as (b: Int, a: Int)).0 // expected-warning {{expression shuffles the elements of this tuple}} |
25 | 25 |
|
26 | | - // Ah, the famous double-shuffle |
27 | | - let (c1, (c2, c3)): (c: Int, (b: Int, a: Int)) = ((a: Int(), b: Int()), c: Int()) |
28 | | - // expected-warning@-1 {{expression shuffles the elements of this tuple}} |
29 | | - // expected-warning@-2 {{expression shuffles the elements of this tuple}} |
30 | | - consume((x, c1, c2, c3)) |
31 | | - } |
| 26 | + // Ah, the famous double-shuffle |
| 27 | + let (c1, (c2, c3)): (c: Int, (b: Int, a: Int)) = ((a: Int(), b: Int()), c: Int()) |
| 28 | + // expected-warning@-1 {{expression shuffles the elements of this tuple}} |
| 29 | + // expected-warning@-2 {{expression shuffles the elements of this tuple}} |
| 30 | + consume((x, c1, c2, c3)) |
| 31 | +} |
0 commit comments