M Mozhi v3.7.0 code

Error reference › Parser diagnostics

PARSE003

invalid assignment target

error
verifiedverified on v3.7.0 categoryparser terminalstable code

What it means

Only variables (`x = ...`), array slots (`a[i] = ...`) and map keys (`m["k"] = ...`) are assignable. Assignments are checked at evaluation time; literals and computed values have no storage to write to.

Trigger condition

An assignment targets something that cannot hold a value — a literal, an expression result, or a non-container property access.

Minimal failing example

5 = x

Verified fix

let x = 5

Assign to a declared variable or to a container slot that exists.

What the interpreter prints

error[PARSE003]: invalid assignment target
  --> app.mz:1:16
 1 | 5 = x
   |                 ^
   |
reason: (the exact problem, with positions)
help:   (a suggested fix appears here)
docs:   https://crossberry-in.github.io/mozhi-doc/errors/PARSE003
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

Declare the target first with `let`/`const`, or restructure so the left side is a variable, array index, or map key.

Related syntax

Assignment, let/const, maps and arrays

Related diagnostics

NAME001

Reference links

Limitations

The check runs at evaluation; a code path that never executes the bad assignment will not report it (the interpreter has no static type checker).