@@ -263,12 +263,16 @@ func forwardFunctionPack<each T>(functions: repeat (each T) -> Bool) {
263
263
takesFunctionPack ( functions: repeat each functions)
264
264
}
265
265
266
- func packOutsideExpansion< each T > ( _ t: repeat each T ) {
266
+ func packOutsideExpansion< each T > (
267
+ t: repeat each T ,
268
+ t2: repeat ( each T ) ? ,
269
+ t3: repeat ( ) -> each T
270
+ ) {
267
271
_ = t
268
- // expected-error@-1{{pack reference 'each T' can only appear in pack expansion }}
272
+ // expected-error@-1{{value pack 'each T' must be referenced with 'each' }}
269
273
270
274
forward ( t)
271
- // expected-error@-1{{pack reference 'each T' can only appear in pack expansion }}
275
+ // expected-error@-1{{value pack 'each T' must be referenced with 'each' }}
272
276
273
277
_ = each t
274
278
// expected-error@-1{{pack reference 'each T' can only appear in pack expansion}}
@@ -282,6 +286,25 @@ func packOutsideExpansion<each T>(_ t: repeat each T) {
282
286
283
287
_ = each tuple
284
288
// expected-error@-1{{pack reference 'each T' can only appear in pack expansion}}
289
+
290
+ // https://github.com/swiftlang/swift/issues/78393
291
+ let _ = ( t2)
292
+ // expected-error@-1{{value pack '(each T)?' must be referenced with 'each'}}
293
+ let _ = t3
294
+ // expected-error@-1{{value pack '() -> each T' must be referenced with 'each'}}
295
+ }
296
+
297
+ do {
298
+ // FIXME: https://github.com/swiftlang/swift/issues/78426
299
+ func f< each T > ( _: ( repeat each T ) -> ( repeat each T ) ) { }
300
+ // expected-error@+2 {{cannot infer type of closure parameter 'x' without a type annotation}}
301
+ // expected-error@+1 {{cannot convert value of type '(Int, Int)' to closure result type '(_: _)'}}
302
+ f { x in
303
+ // Once this issue is fixed, verify that 'x' below is diagnosed correctly.
304
+ // If it is not, please reopen https://github.com/swiftlang/swift/issues/78393.
305
+ let _ = x
306
+ return ( 1 , 2 )
307
+ }
285
308
}
286
309
287
310
func identity< T> ( _ t: T ) -> T { t }
722
745
723
746
init ( base: repeat each Base ) {
724
747
self . base = base
725
- // expected-error@-1 {{pack reference 'each Base' can only appear in pack expansion }}
748
+ // expected-error@-1 {{value pack 'each Base' must be referenced with 'each' }}
726
749
}
727
750
}
728
751
}
0 commit comments