E0010

E0010#

Warning name: unused_pattern

This pattern is unused. This usually happens in pattern matching, and this pattern is completely covered by a prior pattern.

Pattern matching in MoonBit is executed sequentially, from the first branch to the last. If a pattern is covered by a prior pattern, it will never be reached, since all control flow will be directed to the first matching branch.

Erroneous example#

///|
test {
  match Some(1) {
    Some(1) | Some(1) => ()
    Some(2..<_) | Some(2) => ()
    _ | None => ()
  }
}

Suggestion#

This warning can usually be fixed by removing the patterns that are covered.

///|
test {
  match Some(1) {
    Some(1) => ()
    Some(2..<_) => ()
    _ => ()
  }
}