Pancake syntax errors for if/else reported at wrong location
- Dominant language
- Standard ML
- Stars
- 1.2k
- Forks
- 104
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 16
Description
It happens that pancake doesn't support `if ( ) { } else if ( ) { } else { }`, that is, the `else if` pair is not supported and the second if has to be enclosed in `{ .. }`. That is a grumble but not a show stopper.
However, given this syntax, for some reason, the error reported is "failed to see expected token" at `var yv = y;`, which
is much too early:
```
fun foo (1 x, 1 y) {
var xv = x;
while (x < y) {
var yv = y;
if (xv <= y) {
x = x + 8;
}
else if (xv > y) {
x = x + 2;
}
else {
x = x + 1;
}
}
return x;
}
```
This is quite a nuisance, it requires an overcomplicated process of splicing out sections of the file to try to figure out what the error actually is.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the reported Pancake example and trace how the parser records and reports the syntax error around the unsupported else-if form. Confirm where the error location is computed and adjust the behavior so the diagnostic identifies the actual problematic construct rather than var yv.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100