Skip to content

Commit 1cdf721

Browse files
Remove flag from trailing comma tests and move experimental parts to separate file
1 parent e0d416c commit 1cdf721

File tree

2 files changed

+66
-18
lines changed

2 files changed

+66
-18
lines changed

test/Parse/trailing-comma-conditions.swift renamed to test/Parse/trailing-comma-experimental.swift

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// RUN: %target-typecheck-verify-swift -disable-experimental-parser-round-trip -enable-experimental-feature TrailingComma
22

3-
func f(_ block: (Bool) -> Bool) -> Bool { block(true) }
3+
// REQUIRES: asserts
4+
5+
// Condition List
46

57
func testConditionListTrailingComma() {
68
if true, { }
@@ -48,4 +50,36 @@ func testConditionListTrailingComma() {
4850
guard true, , else { return } // expected-error {{expected expression in conditional}}
4951

5052
guard true, { return } // expected-error {{expected 'else' after 'guard' condition}}
53+
54+
while true, { }
55+
}
56+
57+
// Switch Case Pattern List
58+
59+
switch 5 {
60+
case 1, 2,:
61+
break
62+
default:
63+
break
64+
}
65+
66+
protocol P1 { }
67+
protocol P2 { }
68+
69+
// Generic Where Clause List
70+
71+
struct S1<T1, T2,> where T1: P1, T2: P2, { }
72+
73+
protocol P3 {
74+
func f<T1, T2>(a: T1, b: T2) where T1: P1, T2: P2, // expected-error {{expected type}}
75+
}
76+
77+
// Inheritance Clause List
78+
79+
struct S2: P1, P2, { }
80+
81+
struct S3<T>: P1, P2, where T: Equatable { }
82+
83+
protocol P4 {
84+
associatedtype T: P1, P2, // expected-error {{expected type}}
5185
}

test/Parse/trailing-comma.swift

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %target-swift-frontend -parse -verify %s -disable-experimental-parser-round-trip -enable-experimental-feature TrailingComma
1+
// RUN: %target-swift-frontend -parse -verify %s -disable-experimental-parser-round-trip
22

33
// Tuple and Tuple Pattern
44

55
let _ = (a: 1, b: 2, c: 3,)
66

7-
let (_, _,) = (1,)
7+
let (_, _,) = (0,1,)
88

99
// Arguments and Parameters
1010

@@ -33,23 +33,10 @@ protocol P<T1, T2> {
3333
associatedtype T2
3434
}
3535

36-
// Generic Where Clause List
37-
38-
struct S<T1, T2, T3,> where T1: P1, T2: P2, { }
39-
4036
// Closure Capture List
4137

4238
let _ = { [obj1, obj2,] in }
4339

44-
// Switch Case List
45-
46-
switch number {
47-
case 1, 2,:
48-
break
49-
default:
50-
break
51-
}
52-
5340
// Attributes
5441

5542
@Foo(a, b, c,) struct S { }
@@ -75,6 +62,33 @@ macro OptionSet<RawType>() = #externalMacro(module: "SwiftMacros", type: "Option
7562

7663
// Availability Spec List
7764

78-
if #available(iOS 15, watchOS 9, *,) { }
65+
if #unavailable(iOS 15, watchOS 9,) { }
66+
67+
// The following cases are only supported with the 'TrailingComma' experimental feature flag enabled
68+
69+
// Switch Case Pattern List
70+
71+
switch number {
72+
case 1, 2,: // expected-error {{expected pattern}}
73+
break
74+
default:
75+
break
76+
}
77+
78+
// Generic Where Clause List
79+
80+
struct S<T1, T2, T3,> where T1: P1, T2: P2, { } // expected-error {{expected type}}
81+
82+
// Inheritance Clause List
83+
84+
struct S: P1, P2, P3, { } // expected-error {{expected type}}
85+
86+
struct S<T>: P1, P2, P3, where T: Equatable { } // expected-error {{expected type}} expected-error {{expected '{' in struct}}
87+
88+
// Condition List
89+
90+
if true, { } // expected-error {{expected '{' after 'if' condition}}
91+
92+
guard true, else { } // expected-error {{expected expression in conditional}}
7993

80-
if #unavailable(iOS 15, watchOS 9,) { }
94+
while true, { } // expected-error {{expected '{' after 'while' condition}}

0 commit comments

Comments
 (0)