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
afterMessageCount =uintFunc() // expected-error {{cannot assign value of type 'UInt' to type 'Int?'}}
247
+
}
248
+
249
+
// <rdar://problem/19997471> Swift: Incorrect compile error when calling a function inside a closure
250
+
func f19997471(_ x:String){}
251
+
func f19997471(_ x:Int){}
252
+
253
+
func someGeneric19997471<T>(_ x:T){
254
+
takeVoidVoidFn{
255
+
f19997471(x) // expected-error {{cannot invoke 'f19997471' with an argument list of type '(T)'}}
256
+
// expected-note @-1 {{overloads for 'f19997471' exist with these partially matching parameter lists: (String), (Int)}}
257
+
}
258
+
}
259
+
260
+
// <rdar://problem/20371273> Type errors inside anonymous functions don't provide enough information
261
+
func f20371273(){
262
+
letx:[Int]=[1,2,3,4]
263
+
lety:UInt=4
264
+
x.filter{ $0 == y } // expected-error {{binary operator '==' cannot be applied to operands of type 'Int' and 'UInt'}}
265
+
// expected-note @-1 {{overloads for '==' exist with these partially matching parameter lists: (UInt, UInt), (Int, Int)}}
266
+
}
267
+
268
+
269
+
270
+
271
+
// <rdar://problem/20921068> Swift fails to compile: [0].map() { _ in let r = (1,2).0; return r }
272
+
[0].map{ // expected-error {{unable to infer closure return type in current context}}
273
+
_ in
274
+
letr=(1,2).0
275
+
return r
276
+
}
277
+
278
+
279
+
// <rdar://problem/21078316> Less than useful error message when using map on optional dictionary type
280
+
func rdar21078316(){
281
+
varfoo:[String:String]?
282
+
varbar:[(String,String)]?
283
+
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
+
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
+
// <rdar://problem/20868864> QoI: Cannot invoke 'function' with an argument list of type 'type'
294
+
func foo20868864(_ callback:([String])->()){}
295
+
func rdar20868864(_ s:String){
296
+
vars= s
297
+
foo20868864{(strings:[String])in
298
+
s = strings // expected-error {{cannot assign value of type '[String]' to type 'String'}}
299
+
}
300
+
}
301
+
302
+
// <rdar://problem/22058555> crash in cs diags in withCString
303
+
func r22058555(){
304
+
varfirstChar:UInt8=0
305
+
"abc".withCString{ chars in
306
+
firstChar =chars[0] // expected-error {{cannot assign value of type 'Int8' to type 'UInt8'}}
afterMessageCount =uintFunc() // expected-error {{cannot assign value of type 'UInt' to type 'Int?'}}
443
-
}
444
-
445
-
// <rdar://problem/19997471> Swift: Incorrect compile error when calling a function inside a closure
446
-
func f19997471(_ x:String){}
447
-
func f19997471(_ x:Int){}
448
-
449
-
func someGeneric19997471<T>(_ x:T){
450
-
takeVoidVoidFn{
451
-
f19997471(x) // expected-error {{cannot invoke 'f19997471' with an argument list of type '(T)'}}
452
-
// expected-note @-1 {{overloads for 'f19997471' exist with these partially matching parameter lists: (String), (Int)}}
453
-
}
454
-
}
455
-
456
-
// <rdar://problem/20371273> Type errors inside anonymous functions don't provide enough information
457
-
func f20371273(){
458
-
letx:[Int]=[1,2,3,4]
459
-
lety:UInt=4
460
-
x.filter{ $0 == y } // expected-error {{binary operator '==' cannot be applied to operands of type 'Int' and 'UInt'}}
461
-
// expected-note @-1 {{overloads for '==' exist with these partially matching parameter lists: (UInt, UInt), (Int, Int)}}
462
-
}
463
-
464
-
465
-
466
-
467
-
// <rdar://problem/20921068> Swift fails to compile: [0].map() { _ in let r = (1,2).0; return r }
468
-
[0].map{ // expected-error {{unable to infer closure return type in current context}}
469
-
_ in
470
-
letr=(1,2).0
471
-
return r
472
-
}
473
-
474
-
475
-
// <rdar://problem/21078316> Less than useful error message when using map on optional dictionary type
476
-
func rdar21078316(){
477
-
varfoo:[String:String]?
478
-
varbar:[(String,String)]?
479
-
bar = foo.map{($0, $1)} // expected-error {{contextual closure type '([String : String]) -> [(String, String)]' expects 1 argument, but 2 were used in closure body}}
480
-
}
481
-
482
-
483
-
// <rdar://problem/20978044> QoI: Poor diagnostic when using an incorrect tuple element in a closure
484
-
varnumbers=[1,2,3]
485
-
zip(numbers, numbers).filter{ $0.2>1} // expected-error {{value of tuple type '(Int, Int)' has no member '2'}}
486
-
487
-
488
-
489
-
// <rdar://problem/20868864> QoI: Cannot invoke 'function' with an argument list of type 'type'
490
-
func foo20868864(_ callback:([String])->()){}
491
-
func rdar20868864(_ s:String){
492
-
vars= s
493
-
foo20868864{(strings:[String])in
494
-
s = strings // expected-error {{cannot assign value of type '[String]' to type 'String'}}
495
-
}
496
-
}
497
-
498
431
// <rdar://problem/20491794> Error message does not tell me what the problem is
499
432
enumColor{
500
433
case Red // expected-note 2 {{did you mean 'Red'?}}
@@ -709,13 +642,7 @@ func segfault23433271(_ a : UnsafeMutableRawPointer) {
709
642
f23433271(a[0]) // expected-error {{type 'UnsafeMutableRawPointer' has no subscript members}}
710
643
}
711
644
712
-
// <rdar://problem/22058555> crash in cs diags in withCString
713
-
func r22058555(){
714
-
varfirstChar:UInt8=0
715
-
"abc".withCString{ chars in
716
-
firstChar =chars[0] // expected-error {{cannot assign value of type 'Int8' to type 'UInt8'}}
717
-
}
718
-
}
645
+
719
646
720
647
// <rdar://problem/23272739> Poor diagnostic due to contextual constraint
0 commit comments