P001 -- Parser Error¶
The tokens are valid but the sequence does not match the grammar. Messages have
the shape expected X, found Y and point at the offending token.
Examples¶
Unbalanced delimiter:
fn main() {
let x = (1;
}
error[P001]: 2:13: expected ')', found ;
Brace where the grammar expects a parameter identifier:
fn main( { }
error[P001]: 1:12: expected identifier, found '{'
Statements on consecutive lines without a separator:
fn main() {
io.println("a")
io.println("b")
}
error[P001]: 3:3: expected ';', found io
Fix¶
- Balance every
(),[]and{}pair. - Check the line and column in the message; the problem is usually the token just before or at it.
- Statements end with
;; only a block's final expression may omit it. A missing separator between two statements is this error.
Notes¶
- The parser stops the pipeline: no type checking happens until P001 is resolved.
- The compiler prints a suggestion for the common cases (
did you mean ...).