Examples
overflow.mul
Well-typed, but overflows i32 at run time.
Source
examples/overflow.mul is stored in the compact layout, as AI agents write it: a space only between two words, no other whitespace. The page lays it out for reading; the Compact button shows the stored text, and Copy always copies it.
// Well-typed, but overflows i32 at run time.
module demo pub fn main()->i32{return 2147483647+1}
Verified IR
What mul ir prints after the verifier has accepted the program.
module demo
fn @main() -> i32 {
b0:
%0 = const.i32 2147483647
%1 = const.i32 1
%2 = add.i32 %0, %1
return %2
}
Run
The value main returns is the exit code of the process.
$ mul run examples/overflow.mul; echo "exit code $?"
examples/overflow.mul:2:39: error[MUL-R002]: i32 overflow in `add` [byte 84]
| module demo pub fn main()->i32{return 2147483647+1}
| ^^^^^^^^^^^^
exit code 1