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
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -252,7 +252,7 @@ struct CC {}
252
252
func callCC<U>(_ f:(CC)->U)->(){}
253
253
254
254
func typeCheckMultiStmtClosureCrash(){
255
-
callCC{ // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{none}}
255
+
callCC{ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{none}}
256
256
_ = $0
257
257
return1
258
258
}
@@ -313,7 +313,7 @@ struct Thing {
313
313
init?(){}
314
314
}
315
315
// This throws a compiler error
316
-
letthings=Thing().map{ thing in // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{34-34=-> <#Result#> }}
316
+
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
317
// Commenting out this makes it compile
318
318
_ = thing
319
319
return thing
@@ -322,7 +322,7 @@ let things = Thing().map { thing in // expected-error {{unable to infer complex
322
322
323
323
// <rdar://problem/21675896> QoI: [Closure return type inference] Swift cannot find members for the result of inlined lambdas with branches
324
324
func r21675896(file :String){
325
-
letx:String={ // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{20-20= () -> <#Result#> in }}
325
+
letx:String={ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{20-20= () -> <#Result#> in }}
// <rdar://problem/20921068> Swift fails to compile: [0].map() { _ in let r = (1,2).0; return r }
363
-
[0].map{ // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{5-5=-> <#Result#> }}
363
+
[0].map{ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{5-5=-> <#Result#> }}
364
364
_ in
365
365
letr=(1,2).0
366
366
return r
@@ -408,7 +408,7 @@ func r20789423() {
408
408
print(p.f(p)()) // expected-error {{cannot convert value of type 'C' to expected argument type 'Int'}}
409
409
// expected-error@-1:11 {{cannot call value of non-function type '()'}}
410
410
411
-
let_f={(v:Int)in // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{23-23=-> <#Result#> }}
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#> }}
myMap(0..<10,{ x in // expected-error{{unable to infer complex closure return type; add explicit type to disambiguate}} {{21-21=-> <#Result#> }} {{educational-notes=complex-closure-inference}}
164
+
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}}
// CHECK: | --> error: unable to infer complex closure return type; add explicit type to disambiguate [insert ' () -> <#Result#> in ']
155
+
// CHECK: | --> error: cannot infer return type for closure with multiple statements; add explicit type to disambiguate [insert ' () -> <#Result#> in ']
Copy file name to clipboardExpand all lines: test/expr/closure/closures.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -403,7 +403,7 @@ Void(0) // expected-error{{argument passed to call that takes no arguments}}
403
403
_ ={0}
404
404
405
405
// <rdar://problem/22086634> "multi-statement closures require an explicit return type" should be an error not a note
406
-
letsamples={ // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{16-16= () -> <#Result#> in }}
406
+
letsamples={ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{16-16= () -> <#Result#> in }}
letclosure={ // expected-error {{unable to infer complex closure return type; add explicit type to disambiguate}} {{16-16= () -> <#Result#> in }}
488
+
letclosure={ // expected-error {{cannot infer return type for closure with multiple statements; add explicit type to disambiguate}} {{16-16= () -> <#Result#> in }}
Copy file name to clipboardExpand all lines: userdocs/diagnostics/complex-closure-inference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ let doubler = {
10
10
If a closure body is not a single expression, it will not be considered when inferring the closure type. This is consistent with how type inference works in other parts of the language, where it proceeds one statement at a time. For example, in the following code an error will be reported because the type of `evenDoubler` cannot be inferred from its surrounding context and no signature was provided:
11
11
12
12
```swift
13
-
// error: unable to infer complex closure return type; add explicit type to disambiguate
13
+
// error: cannot infer return type for closure with multiple statements; add explicit type to disambiguate
0 commit comments