Skip to content

Commit 58a8b75

Browse files
authored
SR-14221: Add tricky parsing test case for trailing closure (#36202)
Add test case for trailing closure. Fixes SR-14221, fixes rdar://74366546
1 parent f1e532c commit 58a8b75

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/Parse/multiple_trailing_closures.swift renamed to test/Parse/trailing_closures.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,13 @@ func produce(fn: () -> Int?, default d: () -> Int) -> Int { // expected-note {{d
123123
// TODO: The diagnostics here are perhaps a little overboard.
124124
_ = produce { 0 } default: { 1 } // expected-error {{missing argument for parameter 'default' in call}} expected-error {{consecutive statements}} expected-error {{'default' label can only appear inside a 'switch' statement}} expected-error {{top-level statement cannot begin with a closure expression}} expected-error {{closure expression is unused}} expected-note {{did you mean to use a 'do' statement?}}
125125
_ = produce { 2 } `default`: { 3 }
126+
127+
func f() -> Int { 42 }
128+
129+
// This should be interpreted as a trailing closure, instead of being
130+
// interpreted as a computed property with undesired initial value.
131+
struct TrickyTest {
132+
var x : Int = f () { // expected-error {{argument passed to call that takes no arguments}}
133+
3
134+
}
135+
}

0 commit comments

Comments
 (0)