E0088
Constant whose value would panic
ErrorComputing a constant's value follows the rules of run time. An operation that would panic at run time is an error at compile time, with the same message: "integer overflow" or "division by zero".
Why
A constant's value is computed before the program runs, so a panic in it would happen on every run. Only what run time would compute is checked: && and || skip their right side as at run time, and a comparison chain stops at its first false pair. Change the value so that it fits in its type, or does not divide by zero.
Broken
const MASK: u8 = 16 * 16
fn main() {
print(MASK)
}
What sisu says
error[E0088]: integer overflow --> E0088.sisu:1:18 | 1 | const MASK: u8 = 16 * 16 | ^^^^^^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0088
Fixed
const MASK: u8 = 16 * 15
fn main() {
print(MASK)
}
Related
- E0040: integer literal too large for
u8.
Sisu