Error reference › Lexer diagnostics
illegal character in source
errorWhat it means
The lexer's scanner has a fixed token set. Characters such as `^`, `|`, `&`, `~` have no meaning in Mozhi (there are no bitwise operators and no caret operator), so they cannot begin any token and are reported as illegal. Identifiers are ASCII (letters, digits, `_`).
Trigger condition
A byte appears where no Mozhi token can start — most often an operator borrowed from another language, or a non-ASCII character inside an identifier.
Minimal failing example
echo(string(5 ^ 3))Verified fix
echo(string(5 ** 3))`**` is the exponentiation operator (verified: `5 ** 3` prints `125`). For logical operations use the keywords `and` / `or` / `!`.
What the interpreter prints
error[LEX001]: illegal character in source
--> app.mz:1:16
1 | echo(string(5 ^ 3))
| ^
|
reason: (the exact problem, with positions)
help: (a suggested fix appears here)
docs: https://crossberry-in.github.io/mozhi-doc/errors/LEX001mozhi --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
Replace the character with the Mozhi equivalent: `^` → `**` for exponentiation, `||` → `or`, `&&` → `and`, `~x` → `!x`. For single quotes around strings, use double quotes. For non-ASCII names, rename using ASCII letters.
Related syntax
Operators, string literals
Related diagnostics
Reference links
Limitations
One diagnostic is emitted per illegal byte; all of them on the same line are grouped under the first one. Bitwise operations do not exist in Mozhi — this is a language property, not a parse failure.