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 '{'
Fix¶
- Balance every
(),[]and{}pair. - Check the line and column in the message; the problem is usually the token just before or at it.
- Statement terminators matter:
let x = 1;needs its semicolon.
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 ...).