diagnostic codes / Traps
E9001 integer-overflow-trap
Integer arithmetic left the range of its type.
E9001integer-overflow-traparithmetic overflow is a defined trap; pass -fast to wrap
| severity | trap |
|---|---|
| band | Traps |
| in the v0 bootstrap | emitted |
| explain | ralt explain E9001 |
Overflow is not undefined and it is not a wrap by default. Every integer operation that can leave the type's range checks, and a defined trap exits 101 with the code, the name, and the source line. `ralt run -fast` selects wrapping instead, and that is the only way to get it.
What it looks like
e9001.tp
use tier core; fn main() -> i32 { let big: i32 = 2147483647; print_i32(big + 1); return 0; }
ralt run e9001.tp tripon trap E9001 integer-overflow-trap at e9001.tp:5 echo $? 101
The trap line is the whole report: no stack trace, no core file, no diagnostic JSON. A harness distinguishes a trap from a build failure by the exit code alone (101 versus 1).
What to do
- Widen the type before the operation: `let big: i64 = 2147483647;`.
- Guard the operation if the input is not trusted.
- Choose wrapping deliberately with `ralt run -fast` when the algorithm is defined modulo the width; the flag belongs after `run`, not before it.
Why the code exists
A wrap in C is the bug that survives a code review and dies in production. A trap at the exact operation makes the failure local, and a binary search over inputs finds the edge.
What ralt explain says
ralt explain E9001 E9001 severity: error name: integer-overflow-trap hint: arithmetic overflow is a defined trap; pass -fast to wrap
Related
- Traps and no-UB /docs/language/traps