OxL Справочник OxL
РусскийEnglish

warning unreachable-arm

warning Стандарт: [§5.5]

Ветка match недостижима.

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✓ проверяется в 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✓ проверяется в 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 · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства