Skip to content

Commit e4ff484

Browse files
Update trailing comma tests with array literal and built-in attributes
1 parent 2ff7492 commit e4ff484

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/Parse/trailing-comma.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// RUN: %target-swift-frontend -parse -verify %s -disable-experimental-parser-round-trip
22

3+
// Array Literal
4+
5+
let values = [1,2,3,]
6+
7+
let values: [Int,] = [] // expected-note {{to match this opening '['}} expected-error {{expected ']' in array type}} expected-error {{expected pattern}}
8+
39
// Tuple and Tuple Pattern
410

511
let _ = (a: 1, b: 2, c: 3,)
@@ -64,6 +70,45 @@ macro OptionSet<RawType>() = #externalMacro(module: "SwiftMacros", type: "Option
6470

6571
if #unavailable(iOS 15, watchOS 9,) { }
6672

73+
if #available(iOS 15,) { } // expected-error {{expected platform name}}
74+
75+
// Built-in Attributes
76+
77+
@inline(never,) // expected-error {{expected declaration}} expected-error {{expected ')' in 'inline' attribute}}
78+
func foo() { }
79+
80+
@available(iOS 15,) // expected-error {{expected platform name}} expected-error {{expected declaration}}
81+
func foo() { }
82+
83+
@backDeployed(before: SwiftStdlib 6.0,) // expected-error {{unexpected ',' separator}}
84+
func foo() { }
85+
86+
struct Foo {
87+
88+
var x: Int
89+
var y: Int
90+
91+
var value: (Int, Int) {
92+
@storageRestrictions(initializes: x, y,) // expected-error {{expected property name in @storageRestrictions list}}
93+
init(initialValue) {
94+
self.x = initialValue.0
95+
self.y = initialValue.1
96+
}
97+
get { (x, y) }
98+
}
99+
100+
}
101+
102+
func f(in: @differentiable(reverse,) (Int) -> Int) { } // expected-warning {{@differentiable' has been renamed to '@differentiable(reverse)' and will be removed in the next release}} expected-error {{unexpected ',' separator}} expected-error {{expected ',' separator}} expected-error {{unnamed parameters must be written with the empty name '_'}}
103+
104+
@derivative(of: Self.other,) // expected-error {{unexpected ',' separator}}
105+
func foo() {}
106+
107+
@transpose(of: S.instanceMethod,) // expected-error {{unexpected ',' separator}}
108+
func transposeInstanceMethodWrtSelf(_ other: S, t: S) -> S {
109+
other + t
110+
}
111+
67112
// The following cases are only supported with the 'TrailingComma' experimental feature flag enabled
68113

69114
// Switch Case Pattern List

0 commit comments

Comments
 (0)