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
Copy file name to clipboardExpand all lines: test/Constraints/closures.swift
+25-24Lines changed: 25 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -100,8 +100,8 @@ func r21544303() {
100
100
inSubcall =false
101
101
102
102
varv2:Bool=false
103
-
v2 =inSubcall
104
-
{ // expected-error {{cannot call value of non-function type 'Bool'}} expected-note {{did you mean to use a 'do' statement?}} {{3-3=do }}
103
+
v2 =inSubcall // expected-error {{cannot call value of non-function type 'Bool'}}
104
+
{
105
105
}
106
106
}
107
107
@@ -114,56 +114,56 @@ func SR3671() {
114
114
{consume($0)}(42)
115
115
;
116
116
117
-
({$0(42)}{consume($0)}) // expected-note {{callee is here}}
117
+
({$0(42)}{consume($0)}) // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
118
118
119
-
{print(42)} // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}} expected-note {{did you mean to use a 'do' statement?}} {{3-3=do }} expected-error {{cannot call value of non-function type '()'}}
119
+
{print(42)} // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}} expected-note {{did you mean to use a 'do' statement?}} {{3-3=do }}
120
120
;
121
121
122
-
({$0(42)}{consume($0)}) // expected-note {{callee is here}}
122
+
({$0(42)}{consume($0)}) // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
123
123
124
-
{print($0)} // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}} expected-error {{cannot call value of non-function type '()'}}
124
+
{print($0)} // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}}
125
125
;
126
126
127
-
({$0(42)}{consume($0)}) // expected-note {{callee is here}}
127
+
({$0(42)}{consume($0)}) // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
128
128
129
-
{[n]inprint(42)} // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}} expected-error {{cannot call value of non-function type '()'}}
129
+
{[n]inprint(42)} // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}}
130
130
;
131
131
132
-
({$0(42)}{consume($0)}) // expected-note {{callee is here}}
132
+
({$0(42)}{consume($0)}) // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
133
133
134
-
{consume($0)}(42) // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}} expected-error {{cannot call value of non-function type '()'}}
134
+
{consume($0)}(42) // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}}
135
135
;
136
136
137
-
({$0(42)}{consume($0)}) // expected-note {{callee is here}}
137
+
({$0(42)}{consume($0)}) // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
138
138
139
-
{(x:Int)inconsume(x)}(42) // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}} expected-error {{cannot call value of non-function type '()'}}
139
+
{(x:Int)inconsume(x)}(42) // expected-warning {{braces here form a trailing closure separated from its callee by multiple newlines}}
140
140
;
141
141
142
142
// This is technically a valid call, so nothing goes wrong until (42)
143
143
144
-
{$0(3)}
145
-
{consume($0)}(42) // expected-error {{cannot call value of non-function type '()'}}
144
+
{$0(3)} // expected-error {{cannot call value of non-function type '()'}}
145
+
{consume($0)}(42)
146
146
;
147
-
({$0(42)})
148
-
{consume($0)}(42) // expected-error {{cannot call value of non-function type '()'}}
147
+
({$0(42)}) // expected-error {{cannot call value of non-function type '()'}}
148
+
{consume($0)}(42)
149
149
;
150
-
{$0(3)}
151
-
{[n]inconsume($0)}(42) // expected-error {{cannot call value of non-function type '()'}}
150
+
{$0(3)} // expected-error {{cannot call value of non-function type '()'}}
151
+
{[n]inconsume($0)}(42)
152
152
;
153
-
({$0(42)})
154
-
{[n]inconsume($0)}(42) // expected-error {{cannot call value of non-function type '()'}}
153
+
({$0(42)}) // expected-error {{cannot call value of non-function type '()'}}
154
+
{[n]inconsume($0)}(42)
155
155
;
156
156
157
157
// Equivalent but more obviously unintended.
158
158
159
-
{$0(3)} // expected-note {{callee is here}}
159
+
{$0(3)} // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
160
160
161
-
{consume($0)}(42) // expected-error {{cannot call value of non-function type '()'}}
161
+
{consume($0)}(42)
162
162
// expected-warning@-1 {{braces here form a trailing closure separated from its callee by multiple newlines}}
163
163
164
-
({$0(3)}) // expected-note {{callee is here}}
164
+
({$0(3)}) // expected-error {{cannot call value of non-function type '()'}} expected-note {{callee is here}}
165
165
166
-
{consume($0)}(42) // expected-error {{cannot call value of non-function type '()'}}
166
+
{consume($0)}(42)
167
167
// expected-warning@-1 {{braces here form a trailing closure separated from its callee by multiple newlines}}
168
168
;
169
169
@@ -407,6 +407,7 @@ func r20789423() {
407
407
408
408
letp:C
409
409
print(p.f(p)()) // expected-error {{cannot convert value of type 'C' to expected argument type 'Int'}}
410
+
// expected-error@-1:11 {{cannot call value of non-function type '()'}}
410
411
411
412
let_f={(v:Int)in // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{23-23=-> String }}
0 commit comments