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
[Parse] Downgrade trailing closure in statement condition error to a warning
In the past, this error was applied inconsistently, so diagnosing it
correctly is now a source-breaking change. Instead, diagnose it correctly,
but as a warning.
if retBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{13-13=(x: }} {{18-18=)}}
157
+
if retBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{13-13=(x: }} {{18-18=)}}
158
158
}
159
-
if retBool {1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{13-14=(x: }} {{19-19=)}}
159
+
if retBool {1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{13-14=(x: }} {{19-19=)}}
160
160
}
161
-
ifretBool(){1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{14-16=x: }} {{21-21=)}}
162
-
}elseifretBool(){0}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{21-24=x: }} {{29-29=)}}
161
+
ifretBool(){1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{14-16=x: }} {{21-21=)}}
162
+
}elseifretBool(){0}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{21-24=x: }} {{29-29=)}}
163
163
}
164
164
165
-
iflet _ = maybeInt {1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{28-28=)}}
165
+
iflet _ = maybeInt {1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{28-28=)}}
166
166
}
167
-
iflet _ =maybeInt{1},true{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{28-28=)}}
167
+
iflet _ =maybeInt{1},true{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{28-28=)}}
168
168
}
169
169
170
-
iflet _ = foo?.map {$0+1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
170
+
iflet _ = foo?.map {$0+1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
171
171
}
172
-
iflet _ = foo?.map(){$0+1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{23-25=}} {{31-31=)}}
172
+
iflet _ = foo?.map(){$0+1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{23-25=}} {{31-31=)}}
173
173
}
174
-
iflet _ = foo, retBool {1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{26-27=(x: }} {{32-32=)}}
174
+
iflet _ = foo, retBool {1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{26-27=(x: }} {{32-32=)}}
175
175
}
176
176
177
-
if obj.meth1(x:1){0}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{20-22=, }} {{27-27=)}}
177
+
if obj.meth1(x:1){0}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{20-22=, }} {{27-27=)}}
178
178
}
179
-
if obj.meth2(1){0}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{17-19=, y: }} {{24-24=)}}
179
+
if obj.meth2(1){0}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{17-19=, y: }} {{24-24=)}}
180
180
}
181
181
182
-
for_inobj.filter{$0 >4}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(by: }} {{31-31=)}}
182
+
for_inobj.filter{$0 >4}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(by: }} {{31-31=)}}
183
183
}
184
-
for_inobj.filter{$0 >4}wheretrue{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(by: }} {{31-31=)}}
184
+
for_inobj.filter{$0 >4}wheretrue{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(by: }} {{31-31=)}}
185
185
}
186
-
for_in[1,2]whereretBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{31-32=(x: }} {{37-37=)}}
186
+
for_in[1,2]whereretBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{31-32=(x: }} {{37-37=)}}
187
187
}
188
188
189
-
whileretBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{16-17=(x: }} {{22-22=)}}
189
+
whileretBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{16-17=(x: }} {{22-22=)}}
190
190
}
191
-
whilelet _ = foo,retBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{29-30=(x: }} {{35-35=)}}
191
+
whilelet _ = foo,retBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{29-30=(x: }} {{35-35=)}}
192
192
}
193
193
194
-
switchretBool{return1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{17-18=(x: }} {{30-30=)}}
194
+
switchretBool{return1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{17-18=(x: }} {{30-30=)}}
195
195
default:break
196
196
}
197
197
198
198
do{
199
199
throwMyErr.A;
200
-
}catchMyErr.A whereretBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{32-33=(x: }} {{38-38=)}}
200
+
}catchMyErr.A whereretBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{32-33=(x: }} {{38-38=)}}
201
201
}catch{}
202
202
203
203
iflet _ =maybeInt{1}, retBool {1}{}
204
-
// expected-error@-1 {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{28-28=)}}
205
-
// expected-error@-2 {{trailing closure requires parentheses for disambiguation in this context}} {{37-38=(x: }} {{43-43=)}}
204
+
// expected-warning@-1 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{28-28=)}}
205
+
// expected-warning@-2 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{37-38=(x: }} {{43-43=)}}
206
206
207
-
iflet _ = foo?.map {$0+1}.map{$0+1}{} // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{33-34=(}} {{40-40=)}}
208
-
// expected-error@-1 {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
207
+
iflet _ = foo?.map {$0+1}.map{$0+1}{} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{33-34=(}} {{40-40=)}}
208
+
// expected-warning@-1 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
209
209
210
-
iflet _ = foo?.map {$0+1}.map({$0+1}){} // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
210
+
iflet _ = foo?.map {$0+1}.map({$0+1}){} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
211
211
212
-
iflet _ = foo?.map {$0+1}.map({$0+1}).map{$0+1}{} // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{45-45=(}} {{51-51=)}}
213
-
// expected-error@-1 {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
212
+
iflet _ = foo?.map {$0+1}.map({$0+1}).map{$0+1}{} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{45-45=(}} {{51-51=)}}
213
+
// expected-warning@-1 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
214
214
215
-
iftwoClosureArgs({}){}{} // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{23-25=, }} {{27-27=)}}
215
+
iftwoClosureArgs({}){}{} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{23-25=, }} {{27-27=)}}
216
216
217
217
iflet _ =(foo?.map{$0+1}.map({$0+1}).map{$0+1}){} // OK
if !id {true}{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
226
+
if !id {true}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
227
227
228
-
if id {true}==true{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
228
+
if id {true}==true{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
229
229
230
-
iftrue== id {true}{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
230
+
iftrue== id {true}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
231
231
232
-
if id {true}?true:false{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
232
+
if id {true}?true:false{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
233
233
234
-
iftrue?id{true}:false{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
234
+
iftrue?id{true}:false{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
235
235
236
-
iftrue?true: id {false}{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
236
+
iftrue?true: id {false}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
237
237
238
-
if id {[false,true]}[0]{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
238
+
if id {[false,true]}[0]{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
239
239
240
-
if id {{true}}(){return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
240
+
if id {{true}}(){return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
241
241
242
-
if any {true}as!Bool{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
242
+
if any {true}as!Bool{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
243
243
244
-
iflet _ = any {"test"}as?Int{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
244
+
iflet _ = any {"test"}as?Int{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
245
245
246
-
if any {"test"} is Int{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
246
+
if any {"test"} is Int{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
247
247
248
-
iflet _ = id {[]as[Int]?}?.first{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
248
+
iflet _ = id {[]as[Int]?}?.first{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
249
249
250
-
if id {trueasBool?}! {return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
250
+
if id {trueasBool?}! {return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
251
251
252
-
if case id {1}=1{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
252
+
if case id {1}=1{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
253
253
254
-
if case 1=id{1}{return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
254
+
if case 1=id{1}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
255
255
256
-
if case 1=id{1} /*comment*/ {return} // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
256
+
if case 1=id{1} /*comment*/ {return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
0 commit comments