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

Docs

XO0421: integer literal does not fit its type

error · reported by the checker

An integer literal takes the integer type expected in context (Int by default), and its value must fit that type: 300 is not an Int8, 9223372036854775808 is not an Int, and a negative literal is not an unsigned type. A minus written directly on the literal makes a negative literal, so a type’s minimum is written -128 or -9223372036854775808; with parentheses, -(128), the literal must fit alone. See core 1.6.

Example

fn main(os: Os) {
  let b: Int8 = 300
  os.stdio.println("${b}")
}

Fix

fn main(os: Os) {
  let b: Int16 = 300
  os.stdio.println("${b}")
}

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