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
// expected-note@-1{{parameter 'ac1' is implicitly non-escaping because it was declared @autoclosure}}
204
204
acceptNothingToInt({ac1($0)})
205
-
// expected-error@-1{{cannot convert value of type '(_) -> Int' to expected argument type '() -> Int'}}
205
+
// expected-error@-1{{contextual closure type '() -> Int' expects 0 arguments, but 1 was used in closure body}}
206
206
// FIXME: expected-error@-2{{closure use of non-escaping parameter 'ac1' may allow it to escape}}
207
207
}
208
208
@@ -323,4 +323,4 @@ func r20789423() {
323
323
324
324
}
325
325
326
-
326
+
letf:(Int,Int)->Void={ x in} // expected-error {{contextual closure type specifies '(Int, Int)', but 1 was used in closure body, try adding extra parentheses around the single tuple argument}}
Copy file name to clipboardExpand all lines: test/expr/closure/default_args.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@
3
3
func simple_default_args(){
4
4
// <rdar://problem/22753605> QoI: bad diagnostic when closure has default argument
5
5
let _ :(Int)->Int={(x : Int =1)in x+1} // expected-error{{default arguments are not allowed in closures}} {{36-39=}}
6
-
let _ :()->Int={(_ x :Int=1)in x+1} // expected-error{{cannot convert value of type '(Int) -> Int' to specified type '() -> Int'}} expected-error {{default arguments are not allowed in closures}} {{35-38=}}
7
-
let _ :()->Int={(_ x :Int)in x+1} // expected-error{{cannot convert value of type '(Int) -> Int' to specified type '() -> Int'}}
6
+
let _ :()->Int={(_ x :Int=1)in x+1} // expected-error{{contextual closure type '() -> Int' expects 0 arguments, but 1 was used in closure body}} expected-error {{default arguments are not allowed in closures}} {{35-38=}}
7
+
let _ :()->Int={(_ x :Int)in x+1} // expected-error{{contextual closure type '() -> Int' expects 0 arguments, but 1 was used in closure body}}
testfunc2({ $0 +1}) // expected-error {{binary operator '+' cannot be applied to operands of type '((), Int)' and 'Int'}} expected-note {{expected an argument list of type '(Int, Int)'}}
0 commit comments