parser recovery should be much more conservative
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 218
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 8
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the parser's syntax-error recovery logic and the code that chooses expected recovery tokens. Review how recovery on punctuation currently affects the syntax tree, then define and test a restricted keyword set such as struct and trait; done means recovery no longer resumes from arbitrary tokens or produces misleading downstream analysis errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100