-
Notifications
You must be signed in to change notification settings - Fork 210
Description
The parser attempts to "recover" after a syntax error by searching forward for some expected token (eg the right paren when parsing a function parameter list); if it finds an instance of that token, it proceeds with parsing from that point onward (eg parses an optional return type annotation and function body), and reports an error.
We currently allow recovery on all sorts of tokens (like parens, braces, operators, etc). This can lead to an incorrect syntax tree, which we attempt to analyze, and then report misleading errors to the user.
We should only allow recovery on a select set of keywords (like struct, trait, etc), so that when we hit a syntax error and recover, we can be somewhat confident that the tree we produce from that point onward will be sensible.