M Mozhi v3.7.0 code

Error reference › Lexer diagnostics

LEX002

unterminated string literal

error
verifiedverified on v3.7.0 categorylexer terminalstable code

What it means

The lexer scans from the opening `"` to the next `"`. When the input ends first, the string is unterminated — usually a missing quote or an accidentally swapped quote character.

Trigger condition

A string literal reaches the end of the input without a closing double quote.

Minimal failing example

let msg = "hello

Verified fix

let msg = "hello"

The diagnostic names the line and column where the string started, so you can find the opening quote even in long files.

What the interpreter prints

error[LEX002]: unterminated string literal
  --> app.mz:1:16
 1 | let msg = "hello
   |                 ^
   |
reason: (the exact problem, with positions)
help:   (a suggested fix appears here)
docs:   https://crossberry-in.github.io/mozhi-doc/errors/LEX002
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

Add the closing quote. If the string legitimately contains a quote character, escape it as `\"`.

Related syntax

String literals

Related diagnostics

LEX003

Reference links

Limitations

For backward compatibility the token is still produced (running to end of input) in addition to the diagnostic, so downstream errors may also appear.