Lyricdev
GitHub

LYR-LEX0003

a numeric literal with a suffix that does not fit it

error ยท spec 01-lexical

A number carries a suffix that is no type's (10i7), an integer suffix on a float literal (1.5u8), or a float suffix on a literal with a base prefix (0b1f32).

Explanation

A suffix names the literal's type: i8 to i64 and u8 to u64 for integers, f32 and f64 for floats. An integer suffix on a literal with a point or an exponent would make a float an integer, and a prefixed literal (0x, 0o, 0b) is an integer always.

Write a suffix that fits the literal, or convert the value with as.

Wrong

fn main(): void {
    let x = 1.5u8;
    let _ = x;
}
fn main(): void {
    let x = 1.5f32;
    let _ = x;
}