E1068: integer literal outside the range of its type

View source

An integer literal must fit the type it takes.

An integer literal must fit the type it takes. A suffixed literal such as 300u8 has its type from the suffix. An unsuffixed literal takes the type of the binding or of the other operand, so x + 300 with x: u8 is rejected at the literal (ADR-0119). The message names the literal and the type. The error points at the literal, or at the statement when the type comes from the binding. Int is a 32-bit signed integer and Usize a 64-bit unsigned one, so 3000000000 is out of range for an Int wherever an Int is taken: an initializer, an assignment, an argument, a return value, a field, an operand, an element, a constant or a buffer index.

Example

actus
verb main() {
    erg small: u8 = 300u8;
}
actus
verb main() {
    erg x: u8 = 200u8;
    erg y = x + 300;
}
actus
const LIMIT: Int = 3000000000;

verb main() {
}
actus
struct Sample {
    count: Int,
}

verb main() {
    erg sample = Sample { count: 3000000000 };
}

Fix

Use a value that fits, or a wider type. A cast of a literal is checked with its own code, E1091.

actus
verb main() {
    erg small: u16 = 300u16;
}
actus
verb main() {
    erg x: u8 = 200u8;
    erg y = x + 55;
}

Run actus explain E1068 in your terminal to read this entry offline. Browse Ownership & types or all error codes.