M Mozhi v3.7.0 code

Error reference › Runtime diagnostics

RUNTIME001

type mismatch

error
verifiedverified on v3.7.0 categoryruntime terminalstable code

What it means

Mozhi is dynamically typed with per-operator type rules. Arithmetic requires numbers (string concatenation with `+` is the exception), comparisons need comparable types, and index types are fixed per container.

Trigger condition

An operator is applied to a value type it cannot work with — e.g. subtraction on strings, `!` on a non-boolean, ordering `null` values, indexing an array with a string.

Minimal failing example

echo("total: " - 5)

Verified fix

echo("total: " + string(5))

Use `+` for string concatenation and `string(...)` conversions to move between types.

What the interpreter prints

error[RUNTIME001]: type mismatch
  --> app.mz:1:16
 1 | echo("total: " - 5)
   |                 ^
   |
reason: (the exact problem, with positions)
help:   (a suggested fix appears here)
docs:   https://crossberry-in.github.io/mozhi-doc/errors/RUNTIME001
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

Print the operands with `string(...)` first to see their types, then convert operands explicitly before the operation.

Related syntax

Operators, type conversions

Related diagnostics

RUNTIME003RUNTIME004

Reference links

Limitations

The diagnostic names the operation in the message (as before v3.2.0) and adds the code/span; it does not yet print the operand types.