Error reference › Parser diagnostics
expected an expression
errorWhat it means
Every expression must begin with a prefix-able token (literal, identifier, `(`, `[`, `{`, unary operator, `fn`, ...). Tokens that only occur *between* operands (like `)` or `,`) cannot start an expression.
Trigger condition
An expression is required but the next token cannot start one — for example a closing parenthesis or operator in operand position.
Minimal failing example
let x = ( + 1)Verified fix
let x = (1 + 1)When the real problem is an illegal character, the parser groups this diagnostic under the LEX001 root cause.
What the interpreter prints
error[PARSE004]: expected an expression
--> app.mz:1:16
1 | let x = ( + 1)
| ^
|
reason: (the exact problem, with positions)
help: (a suggested fix appears here)
docs: https://crossberry-in.github.io/mozhi-doc/errors/PARSE004mozhi --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
Look at what precedes the position: usually an operand is missing between two operators, or a stray closing delimiter appeared early.
Related syntax
Expressions, operators
Related diagnostics
Reference links
Limitations
Position points at the token that could not start the expression; the actual omission is usually slightly earlier in the line.