M Mozhi v3.7.0 code

Error reference › Name-resolution diagnostics

NAME001

undefined variable

error
verifiedverified on v3.7.0 categoryname terminalstable code

What it means

Identifier reads walk the local scope chain, then fall back to the built-in table. If neither knows the name, the lookup fails. The diagnostic suggests the closest known name (edit distance ≤ 2) from visible variables and built-ins.

Trigger condition

A variable is read that was never declared in any visible scope.

Minimal failing example

let count = 1
echo(conut)

Verified fix

let count = 1
echo(count)

The message includes a `did you mean 'count'?` hint when a close match exists.

What the interpreter prints

error[NAME001]: undefined variable
  --> app.mz:1:16
 1 | let count = 1
   |                 ^
   |
reason: (the exact problem, with positions)
help:   (a suggested fix appears here)
docs:   https://crossberry-in.github.io/mozhi-doc/errors/NAME001
Run 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

Fix the typo (see the suggestion), or declare the variable with `let`. Remember that user variables may shadow built-ins since v3.1.1.

Related syntax

Variables and scopes, built-ins

Related diagnostics

NAME002PARSE003

Reference links

Limitations

Suggestions are heuristic (edit distance ≤ 2). Scope-chain walk is bounded by the frames live at the failure point.