Home / Docs / Diagnostics
U2008: Unreachable arm or misplaced else
Release v0.4.0
An else arm is the last arm of a when (spec/02 §8), since any arm after it is never reached. U2008 also reports the other arms that no value reaches: an arm that tests a variant or a literal that an earlier arm already tests, and an else after arms that match every variant of the kind (ADR 0024). The diagnostic points at the unreachable arm and at the arm that makes it unreachable.
The repair at a glance
diff
module demo
pub kind Level = Low | High
pub rank(level: Level) -> Int
=
when level
- else -> 0
is High -> 2
+ else -> 0Failing example
una
module demo
pub kind Level = Low | High
pub rank(level: Level) -> Int
=
when level
else -> 0
is High -> 2Fixed example
una
module demo
pub kind Level = Low | High
pub rank(level: Level) -> Int
=
when level
is High -> 2
else -> 0