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}}
0 commit comments