M Mozhi v3.7.0 code

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

CodeTitleSeverity
LEX001illegal character in sourceerror
LEX002unterminated string literalerror
LEX003unknown escape sequence in stringwarning
LEX004unterminated block commenterror

Parser diagnostics

CodeTitleSeverity
PARSE001unexpected tokenerror
PARSE002unbalanced delimitererror
PARSE003invalid assignment targeterror
PARSE004expected an expressionerror
PARSE005unexpected end of inputerror

Name-resolution diagnostics

CodeTitleSeverity
NAME001undefined variableerror
NAME002undefined functionerror

Runtime diagnostics

CodeTitleSeverity
RUNTIME001type mismatcherror
RUNTIME002division by zeroerror
RUNTIME003index out of rangeerror
RUNTIME004undefined methoderror
RUNTIME006stack overflowerror
RUNTIME007value is not callableerror
RUNTIME009runtime errorerror
RUNTIME010wrong number of argumentserror

Import diagnostics

CodeTitleSeverity
IMPORT001module not founderror
IMPORT002invalid import syntaxerror
IMPORT003imported module contains errorserror

Standard-library diagnostics

CodeTitleSeverity
STDLIB001invalid argument to built-in functionerror

CLI diagnostics

CodeTitleSeverity
CLI001cannot open fileerror
CLI002unknown commanderror
CLI003missing required argumenterror
CLI004diagnostic output truncatedinfo