OxL Справочник OxL
РусскийEnglish

error literal-overflow

error Стандарт: [§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✓ проверяется в CI
fn main() {
  let level: u8 = 300      // <- literal-overflow (u8 holds 0..=255)
}
error
literal-overflow

How to fix#

oxl✓ проверяется в 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 · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства