We need a better heuristic for error recovery
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 13
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Usually, when an error occurs while parsing a program, we want to interrupt the parsing process, because continuing it would result in many errors that only exist because of the first one (panic mode).
On these cases, we decide on some heuristics to skip some portion of the code until we think it is safe to start parsing again without garbage errors.
For languages with statements, the end of a statement is a good place to synchronize the errors. Pinto, however, has no statements, and decided to do it based on declarations instead. However, doing so will prevent many useful errors from being properly reported.
For instance:
```
let improperFunction () _ = 10
// ^ syntax error
10
// ^^ syntax error
let improperFunction2 () _ = 10
// ^ syntax error
```
In the code above, 3 errors should be emitted.
1. The syntax for a function declaration is incorrect.
2. A integer literal is used where a declaration is expected.
3. The syntax for a function declaration is incorrect.
However, error 2 will be ignored, because everything between 1 and the last `let` declaration will be skipped.
This issue proposes that we come up with better synchronization heuristics considering the nature of the syntax of pint°.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the parser's current panic-mode synchronization based on declarations, then reproduce the example with the three malformed declarations and intervening integer literal. Define improved synchronization heuristics for Pinto's declaration-based syntax; done means the parser reports all three errors instead of skipping the middle one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100