OxL Reference

warning unreachable-arm

warning Standard: [§5.5]

What it means#

An arm is unreachable if the earlier arms already cover every value it could match, for example an arm after _ or a repeated pattern (§5.5). This is a warning by default, configurable in [lint].

Example#

oxl✓ checked in CI
enum Role { User, Admin }

fn label(r: Role) -> str {
  match r {
    _ => "other"
    Role.Admin => "admin"      // <- unreachable-arm
  }
}
error
unreachable-arm

How to fix#

oxl✓ checked in CI
enum Role { User, Admin }

fn label(r: Role) -> str {
  match r {
    Role.Admin => "admin"
    _ => "other"
  }
}

Move the specific arm before the general one, or delete the dead arm.

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides