Pattern variables can be introduced by case labels with a case pattern, either by the pattern itself or by a guard, and are in scope for the relevant parts of the associated switch expression (§6.3.1.6) or switch statement (§6.3.2.6).
The following rules applies to case labels:
- A pattern variable is introduced by a
caselabel with acasepatternpifpcontains a declaration of the pattern variable. - If a
casepattern in a guardedcaselabel contains a declaration of a pattern variable then the pattern variable is definitely matched in the associated guard. - A pattern variable is introduced by a guarded
caselabel if it is introduced by the associated guard when true (§6.3.1).