Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · XO0430

Docs

XO0430: misspelled constant pattern

error · reported by the checker

A bare name in a pattern that is a const matches by equality. A name that is not a constant would bind a new variable that matches everything, so a name spelled like a constant (upper case, digits and underscores) that resolves to nothing is an error: the usual cause is a typo in the constant’s name. See core 3.5.

Example

const OK = 200

fn f(s: Int) -> Bool {
  match s {
    OKK => true
    _ => false
  }
}

Fix

const OK = 200

fn f(s: Int) -> Bool {
  match s {
    OK => true
    _ => false
  }
}

Run xo explain XO0430 for this text in a terminal, or see section 10.6 of the specification.