|
1 | | -// RUN: %target-typecheck-verify-swift -swift-version 5 |
| 1 | +// RUN: %target-typecheck-verify-swift -swift-version 6 -verify-additional-prefix swift6- |
| 2 | +// RUN: %target-typecheck-verify-swift -swift-version 7 -verify-additional-prefix swift7- |
| 3 | + |
| 4 | +// REQUIRES: swift7 |
2 | 5 |
|
3 | 6 | func consume<T>(_ x: T) {} // Suppress unused variable warnings |
4 | 7 |
|
5 | 8 | func shuffle_through_initialization() { |
6 | 9 | let a = (x: 1, y: 2) |
7 | 10 | let b: (y: Int, x: Int) |
8 | | - b = a // expected-warning {{implicit reordering of tuple elements from 'x:y:' to 'y:x:' is deprecated}} |
| 11 | + b = a |
| 12 | + // expected-swift6-warning@-1 {{implicit reordering of tuple elements from 'x:y:' to 'y:x:' is deprecated; this will be an error in a future Swift language mode}} |
| 13 | + // expected-swift7-error@-2 {{cannot implicitly reorder tuple elements from 'x:y:' to 'y:x:'}} |
9 | 14 | consume(b) |
10 | 15 | } |
11 | 16 |
|
12 | 17 | func shuffle_raw_label(_ t: (`a b`: Int, `c d`: Int)) { |
13 | 18 | let _: (`c d`: Int, `a b`: Int) = t |
14 | | - // expected-warning@-1 {{implicit reordering of tuple elements from '`a b`:`c d`:' to '`c d`:`a b`:' is deprecated}} |
| 19 | + // expected-swift6-warning@-1 {{implicit reordering of tuple elements from '`a b`:`c d`:' to '`c d`:`a b`:' is deprecated; this will be an error in a future Swift language mode}} |
| 20 | + // expected-swift7-error@-2 {{cannot implicitly reorder tuple elements from '`a b`:`c d`:' to '`c d`:`a b`:'}} |
15 | 21 | } |
16 | 22 |
|
17 | 23 | func shuffle_through_destructuring() { |
18 | 24 | let a = (x: 1, y: 2) |
19 | | - let (y: b, x: c) = a // expected-warning {{implicit reordering of tuple elements from 'x:y:' to 'y:x:' is deprecated}} |
| 25 | + let (y: b, x: c) = a |
| 26 | + // expected-swift6-warning@-1 {{implicit reordering of tuple elements from 'x:y:' to 'y:x:' is deprecated; this will be an error in a future Swift language mode}} |
| 27 | + // expected-swift7-error@-2 {{cannot implicitly reorder tuple elements from 'x:y:' to 'y:x:'}} |
20 | 28 | consume((b, c)) |
21 | 29 | } |
22 | 30 |
|
23 | 31 | func shuffle_through_call() { |
24 | 32 | func foo(_ : (x: Int, y: Int)) {} |
25 | | - foo((y: 5, x: 10)) // expected-warning {{implicit reordering of tuple elements from 'y:x:' to 'x:y:' is deprecated}} |
| 33 | + foo((y: 5, x: 10)) |
| 34 | + // expected-swift6-warning@-1 {{implicit reordering of tuple elements from 'y:x:' to 'x:y:' is deprecated; this will be an error in a future Swift language mode}} |
| 35 | + // expected-swift7-error@-2 {{cannot implicitly reorder tuple elements from 'y:x:' to 'x:y:'}} |
26 | 36 | } |
27 | 37 |
|
28 | 38 | func shuffle_through_cast() { |
29 | | - let x = ((a: Int(), b: Int()) as (b: Int, a: Int)).0 // expected-warning {{implicit reordering of tuple elements from 'a:b:' to 'b:a:' is deprecated}} |
| 39 | + let x = ((a: Int(), b: Int()) as (b: Int, a: Int)).0 |
| 40 | + // expected-swift6-warning@-1 {{implicit reordering of tuple elements from 'a:b:' to 'b:a:' is deprecated; this will be an error in a future Swift language mode}} |
| 41 | + // expected-swift7-error@-2 {{cannot implicitly reorder tuple elements from 'a:b:' to 'b:a:'}} |
30 | 42 |
|
31 | 43 | // Ah, the famous double-shuffle |
32 | 44 | let (c1, (c2, c3)): (c: Int, (b: Int, a: Int)) = ((a: Int(), b: Int()), c: Int()) |
33 | | - // expected-warning@-1 {{implicit reordering of tuple elements from 'a:b:' to 'b:a:' is deprecated}} |
34 | | - // expected-warning@-2 {{implicit reordering of tuple elements from '_:c:' to 'c:_:' is deprecated}} |
| 45 | + // expected-swift6-warning@-1 {{implicit reordering of tuple elements from 'a:b:' to 'b:a:' is deprecated; this will be an error in a future Swift language mode}} |
| 46 | + // expected-swift6-warning@-2 {{implicit reordering of tuple elements from '_:c:' to 'c:_:' is deprecated; this will be an error in a future Swift language mode}} |
| 47 | + // expected-swift7-error@-3 {{cannot implicitly reorder tuple elements from 'a:b:' to 'b:a:'}} |
| 48 | + // expected-swift7-error@-4 {{cannot implicitly reorder tuple elements from '_:c:' to 'c:_:'}} |
35 | 49 | consume((x, c1, c2, c3)) |
36 | 50 | } |
0 commit comments