OxL Reference

error literal-overflow

error Standard: [§1.5]

What it means#

An integer literal that does not fit the type inferred from its context is a compile-time error (§1.5). A literal without a suffix gets its type from the context, or i64 if there is none.

Example#

oxl✓ checked in CI
fn main() {
  let level: u8 = 300      // <- literal-overflow (u8 holds 0..=255)
}
error
literal-overflow

How to fix#

oxl✓ checked in CI
fn main() {
  let level: u16 = 300
}

Use a wider type, a smaller value, or a suffix that selects the intended type (300u16). Converting at run time with as panics when the value is out of range (§3.1).

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides