Mozhi error reference
Every diagnostic produced by the Mozhi interpreter carries a stable code, a source span,
a suggested fix and a link to its page. These pages document the v3.7.0 central
diagnostics registry — the same table the interpreter's CLI is built from, and this
site is generated from that registry, so codes and docs cannot drift apart. For the legacy
v2.x MZ1xxx–MZ4xxx specification pages, see
the archived MZ1001 page (also kept under errors/).
Anatomy of a diagnostic
error[LEX001]: illegal character in source
--> app.mz:1:16
1 | echo(string(5 ^ 3))
| ^
|
reason: the character '^' is not part of the Mozhi language
help: exponentiation is written with '**' in Mozhi, e.g. 5 ** 3
docs: https://crossberry-in.github.io/mozhi-doc/errors/LEX001
── AI Diagnosis ────────────────────────────
Replace `^` with `**`. For example, change `5 ^ 3` to `5 ** 3`.
Note: AI-generated suggestion — may be wrong; the local diagnosis above is authoritative.
Machine-readable output
Run mozhi --json run app.mz — diagnostics are printed to stderr as JSON
(schema mozhi.diagnostics.v1) with fields
code, severity, category, message, reason, help, file, line, column, endLine, endColumn,
documentation. Coordinates are 1-based; a column counts Unicode code points and a tab
counts as one column. See the CLI reference.
Free AI Diagnosis
Interactive runs attach a free, anonymous explanation below the local diagnostics — no API
key, no account. Details and privacy notes: AI Diagnosis.
Lexer diagnostics
| Code | Title | Severity |
|---|
LEX001 | illegal character in source | error |
LEX002 | unterminated string literal | error |
LEX003 | unknown escape sequence in string | warning |
LEX004 | unterminated block comment | error |
Parser diagnostics
Name-resolution diagnostics
| Code | Title | Severity |
|---|
NAME001 | undefined variable | error |
NAME002 | undefined function | error |
Runtime diagnostics
Import diagnostics
Standard-library diagnostics
| Code | Title | Severity |
|---|
STDLIB001 | invalid argument to built-in function | error |
CLI diagnostics
| Code | Title | Severity |
|---|
CLI001 | cannot open file | error |
CLI002 | unknown command | error |
CLI003 | missing required argument | error |
CLI004 | diagnostic output truncated | info |