You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parser: Explicitly ban closures at the beginning of statements.
This already can't happen in most circumstances because of trailing closures, but we didn't explicitly disallow it at the beginning of a BraceStmt or following a statement production. Fixes the parser part of rdar://problem/17850752 (though there's a type checker bug there too).
Swift SVN r21663
Copy file name to clipboardExpand all lines: test/decl/func/static_func.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ static override func gf5() {} // expected-error {{static methods may only be dec
13
13
classoverridefunc gf6(){} // expected-error {{class methods may only be declared on a type}}{{1-6=}}
14
14
// expected-error@-1 {{'override' can only be specified on class members}}{{7-15=}}
15
15
16
-
static gf7(){} // expected-error {{expected declaration}} expected-error {{braced block of statements is an unused closure}}
17
-
classgf8(){} // expected-error {{expected '{' in class}} expected-error {{braced block of statements is an unused closure}}
16
+
static gf7(){} // expected-error {{expected declaration}} expected-error {{braced block of statements is an unused closure}} expected-error{{begin with a closure}} expected-note{{discard the result}}
17
+
classgf8(){} // expected-error {{expected '{' in class}} expected-error {{braced block of statements is an unused closure}} expected-error{{begin with a closure}} expected-note{{discard the result}}
18
18
19
19
func inGlobalFunc(){
20
20
static func gf1(){} // expected-error {{static methods may only be declared on a type}}{{3-9=}}
Copy file name to clipboardExpand all lines: test/decl/operators.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ prefix func +// this should be a comment, not an operator
60
60
prefixfunc-/* this also should be a comment, not an operator */
61
61
(arg:Int)->Int{return arg }
62
62
63
-
func+*/(){} // expected-error {{expected identifier in function declaration}} expected-error {{unexpected end of block comment}} expected-error {{braced block of statements is an unused closure}}
63
+
func+*/(){} // expected-error {{expected identifier in function declaration}} expected-error {{unexpected end of block comment}} expected-error {{braced block of statements is an unused closure}} expected-error{{begin with a closure}} expected-note{{discard the result}}
64
64
func errors(){
65
65
*/ // expected-error {{unexpected end of block comment}}
// expected-error {{braced block of statements is an unused closure}}
162
162
}
163
163
164
-
infix operator ?{} // expected-error {{expected operator name in operator declaration}} expected-error {{braced block of statements is an unused closure}}
164
+
infix operator ?{} // expected-error {{expected operator name in operator declaration}} expected-error {{braced block of statements is an unused closure}} expected-error{{begin with a closure}} expected-note{{discard the result}}
iflet{} // expected-error{{expected pattern}} expected-error{{unused closure}} expected-error{{begin with a closure}} expected-note{{discard the result}}
0 commit comments