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
// rdar://47240768 Expand the definition of "simple" pattern to variables bound in patterns
452
+
func testVariablesBoundInPatterns(){
453
+
enumStringB{
454
+
case simple(b:Bool)
455
+
case tuple(b:(Bool,Bool))
456
+
case optional(b:Bool?)
457
+
}
458
+
459
+
// Because Swift enables all kinds of creative binding forms, make sure that
460
+
// variable patterns occuring directly under a `let` or `var` have that
461
+
// introducer stripped by the fixit. All other cases are currently too
462
+
// complicated for the VarDeclUsageChecker.
463
+
switchStringB.simple(b:true){
464
+
case.simple(b:let b)wherefalse: // expected-warning {{immutable value 'b' was never used; consider replacing with '_' or removing it}} {{19-24=_}}
465
+
break
466
+
case.simple(b:var b)wherefalse: // expected-warning {{variable 'b' was never used; consider replacing with '_' or removing it}} {{19-24=_}}
467
+
break
468
+
casevar.simple(b: b): // expected-warning {{variable 'b' was never used; consider replacing with '_' or removing it}} {{23-24=_}}
469
+
break
470
+
case.tuple(b:let(b1, b2))wherefalse:
471
+
// expected-warning@-1 {{immutable value 'b1' was never used; consider replacing with '_' or removing it}} {{23-25=_}}
472
+
// expected-warning@-2 {{immutable value 'b2' was never used; consider replacing with '_' or removing it}} {{27-29=_}}
473
+
break
474
+
case.tuple(b:(let b1,let b2))wherefalse:
475
+
// expected-warning@-1 {{immutable value 'b1' was never used; consider replacing with '_' or removing it}} {{19-25=_}}
476
+
// expected-warning@-2 {{immutable value 'b2' was never used; consider replacing with '_' or removing it}} {{27-33=_}}
477
+
break
478
+
case.tuple(b:(var b1,var b2))wherefalse:
479
+
// expected-warning@-1 {{variable 'b1' was never used; consider replacing with '_' or removing it}} {{19-25=_}}
480
+
// expected-warning@-2 {{variable 'b2' was never used; consider replacing with '_' or removing it}} {{27-33=_}}
481
+
break
482
+
casevar.tuple(b:(b1, b2))wherefalse:
483
+
// expected-warning@-1 {{variable 'b1' was never used; consider replacing with '_' or removing it}} {{23-25=_}}
484
+
// expected-warning@-2 {{variable 'b2' was never used; consider replacing with '_' or removing it}} {{27-29=_}}
485
+
break
486
+
case.tuple(b:let b): // expected-warning {{immutable value 'b' was never used; consider replacing with '_' or removing it}} {{18-23=_}}
487
+
break
488
+
case.optional(b:let x?)wherefalse: // expected-warning {{immutable value 'x' was never used; consider replacing with '_' or removing it}} {{25-26=_}}
489
+
break
490
+
case.optional(b:let.some(x))wherefalse: // expected-warning {{immutable value 'x' was never used; consider replacing with '_' or removing it}} {{31-32=_}}
491
+
break
492
+
caselet.optional(b: x?): // expected-warning {{immutable value 'x' was never used; consider replacing with '_' or removing it}} {{25-26=_}}
493
+
break
494
+
caselet.optional(b:.none): // expected-warning {{'let' pattern has no effect; sub-pattern didn't bind any variables}} {{8-12=}}
0 commit comments