Error reference › Runtime diagnostics
RUNTIME002
division by zero
errorWhat it means
Integer and float division by zero is undefined in Mozhi and reported instead of producing infinity or crashing.
Trigger condition
A `/` or `%` operation has a zero right-hand side.
Minimal failing example
let n = 0
echo(10 / n)Verified fix
let n = 0
if n != 0 { echo(10 / n) } else { echo("n is zero") }Guard the divisor, or use a fallback value.
What the interpreter prints
error[RUNTIME002]: division by zero
--> app.mz:1:16
1 | let n = 0
| ^
|
reason: (the exact problem, with positions)
help: (a suggested fix appears here)
docs: https://crossberry-in.github.io/mozhi-doc/errors/RUNTIME002Run
mozhi --json run app.mz to get the same information as
machine-readable JSON (schema mozhi.diagnostics.v1), or --verbose to
also show grouped related diagnostics. See the CLI reference.Suggested fix
Check the divisor before dividing; for user input, validate with a condition first.
Related syntax
Arithmetic operators
Related diagnostics
Reference links
Limitations
Float division also rejects zero (Mozhi does not produce IEEE infinities).