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
letthings=Thing().map{ thing in // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{34-34=-> <#Result#> }}
317
-
// Commenting out this makes it compile
315
+
316
+
letthings=Thing().map{ thing in
318
317
_ = thing
319
318
return thing
320
319
}
321
320
322
321
323
322
// <rdar://problem/21675896> QoI: [Closure return type inference] Swift cannot find members for the result of inlined lambdas with branches
324
323
func r21675896(file :String){
325
-
letx:String={ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{20-20= () -> <#Result#> in }}
324
+
letx:String={
326
325
iftrue{
327
326
return"foo"
328
327
}
329
328
else{
330
329
return file
331
330
}
332
-
}().pathExtension
331
+
}().pathExtension // expected-error {{value of type 'String' has no member 'pathExtension'}}
// <rdar://problem/20921068> Swift fails to compile: [0].map() { _ in let r = (1,2).0; return r }
363
-
[0].map{ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{5-5=-> <#Result#> }}
362
+
let _ =[0].map{
364
363
_ in
365
364
letr=(1,2).0
366
365
return r
@@ -408,7 +407,7 @@ func r20789423() {
408
407
print(p.f(p)()) // expected-error {{cannot convert value of type 'C' to expected argument type 'Int'}}
409
408
// expected-error@-1:11 {{cannot call value of non-function type '()'}}
410
409
411
-
let_f={(v:Int)in // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{23-23=-> <#Result#> }}
410
+
let_f={(v:Int)in
412
411
print("a")
413
412
return"hi"
414
413
}
@@ -1127,7 +1126,7 @@ func rdar76058892() {
1127
1126
func experiment(arr:[S]?){
1128
1127
test{ // expected-error {{contextual closure type '() -> String' expects 0 arguments, but 1 was used in closure body}}
1129
1128
iflet arr = arr {
1130
-
arr.map($0.test) // expected-note {{anonymous closure parameter '$0' is used here}}
1129
+
arr.map($0.test) // expected-note {{anonymous closure parameter '$0' is used here}} // expected-error {{generic parameter 'T' could not be inferred}}
myMap(0..<10,{ x in // expected-error{{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{21-21=-> <#Result#> }} {{educational-notes=complex-closure-inference}}
164
+
_ =myMap(0..<10,{ x in // expected-error {{'myMap' is unavailable: call the 'map()' method on the sequence}}
block(p) // expected-error {{parameter 'block' expects 2 separate arguments}}
1412
+
}
1413
+
1414
+
f2.forEach{ block in
1415
+
// expected-note@-1 {{'block' declared here}}
1412
1416
block((c, c)) // expected-error {{parameter 'block' expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{11-12=}} {{16-17=}}
1413
1417
block(c, c)
1414
1418
}
1415
1419
1420
+
f2.forEach{ block in
1421
+
block(c, c)
1422
+
}
1423
+
1416
1424
f2.forEach{(block:((Bool,Bool))->())in
1417
1425
// expected-error@-1 {{cannot convert value of type '(((Bool, Bool)) -> ()) -> Void' to expected argument type '(@escaping (Bool, Bool) -> ()) throws -> Void'}}
1418
1426
block(p)
1419
1427
block((c, c))
1420
-
block(c, c)
1428
+
block(c, c) // expected-error {{parameter 'block' expects a single parameter of type '(Bool, Bool)'}}
1421
1429
}
1422
1430
1423
1431
f2.forEach{(block:(Bool,Bool)->())in
1424
-
// expected-note@-1 2{{'block' declared here}}
1432
+
// expected-note@-1 {{'block' declared here}}
1425
1433
block(p) // expected-error {{parameter 'block' expects 2 separate arguments}}
1434
+
}
1435
+
1436
+
f2.forEach{(block:(Bool,Bool)->())in
1437
+
// expected-note@-1 {{'block' declared here}}
1426
1438
block((c, c)) // expected-error {{parameter 'block' expects 2 separate arguments; remove extra parentheses to change tuple into separate arguments}} {{11-12=}} {{16-17=}}
1427
1439
block(c, c)
1428
1440
}
1441
+
1442
+
f2.forEach{(block:(Bool,Bool)->())in
1443
+
block(c, c)
1444
+
}
1429
1445
}
1430
1446
1431
1447
// expected-error@+1 {{cannot create a single-element tuple with an element label}}
0 commit comments