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
Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.
```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```
Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:
```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```
This patch does not implement that part.
_ = x.minElement{ _, _ intrue} // expected-error {{'minElement' has been renamed to 'min(by:)'}} {{9-19=min}} {{none}}
408
408
_ = x.maxElement{ _, _ intrue} // expected-error {{'maxElement' has been renamed to 'max(by:)'}} {{9-19=max}} {{none}}
409
409
_ = x.reverse() // expected-error {{'reverse()' has been renamed to 'reversed()'}} {{9-16=reversed}} {{none}}
410
-
_ = x.startsWith([]){ _ intrue} // expected-error {{'startsWith(_:isEquivalent:)' has been renamed to 'starts(with:by:)'}} {{9-19=starts}} {{20-20=with: }} {{none}}
410
+
_ = x.startsWith([]){ _, _intrue} // expected-error {{'startsWith(_:isEquivalent:)' has been renamed to 'starts(with:by:)'}} {{9-19=starts}} {{20-20=with: }} {{none}}
411
411
_ = x.lexicographicalCompare([]){ _, _ intrue} // expected-error {{'lexicographicalCompare(_:isOrderedBefore:)' has been renamed to 'lexicographicallyPrecedes(_:by:)'}} {{9-31=lexicographicallyPrecedes}}{{none}}
// expected-note@-1{{parameter 'ac1' is implicitly non-escaping because it was declared @autoclosure}}
204
205
acceptNothingToInt({ac1($0)})
205
-
// expected-error@-1{{cannot convert value of type '(_) -> Int' to expected argument type '() -> Int'}}
206
+
// expected-error@-1{{contextual closure type '() -> Int' expects 0 arguments, but 1 were used in closure body}}
206
207
// FIXME: expected-error@-2{{closure use of non-escaping parameter 'ac1' may allow it to escape}}
207
208
}
208
209
@@ -283,13 +284,6 @@ func rdar21078316() {
283
284
bar = foo.map{($0, $1)} // expected-error {{contextual closure type '([String : String]) -> [(String, String)]' expects 1 argument, but 2 were used in closure body}}
284
285
}
285
286
286
-
287
-
// <rdar://problem/20978044> QoI: Poor diagnostic when using an incorrect tuple element in a closure
288
-
varnumbers=[1,2,3]
289
-
zip(numbers, numbers).filter{ $0.2>1} // expected-error {{value of tuple type '(Int, Int)' has no member '2'}}
290
-
291
-
292
-
293
287
// <rdar://problem/20868864> QoI: Cannot invoke 'function' with an argument list of type 'type'
0 commit comments