Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Runtime Checks and Exit Codes

J3 checks for a few mistakes at runtime and stops the program with a clear message instead of corrupting memory.

What is checked

CheckExample
Array and slice boundsxs[10] on a 4-element array
Division by zeron / 0, n % 0
Interpolated string too longA `{...}` string past 512 bytes

A failed check prints file:line: reason. --fast (or [emit] fast = true) removes the bounds-check aborts.

Integer overflow is not an error: it wraps.

Exit codes

CodeMeaning
0Normal exit
101panic(...) was called
102A runtime check failed
128 + nKilled by signal n

Dev builds on x86-64 Linux install a crash handler that prints a symbolized stack trace.

Compile-time checks

These are caught before the program ever runs:

  • Type mismatches, including mixing number types without a conversion
  • A match that misses a variant
  • Import cycles between modules
  • Naming an item that isn’t pub
  • A #[singleton] with a non-constant initializer
  • Writing to a const table