Commit 219c6ac
Fix crash in error annotator when parser fails at EOF
A parse failure with a missing closing `}` at EOF (e.g.,
`context X is { ... ` with no `}` before EOF) constructs an
`At` whose `endOffset` is one past the end of the last line
computed by `lineRangeOf`. Two `require` calls in
`RiddlParserInput.annotateErrorLine` then threw
`IllegalArgumentException: requirement failed: fail: 58 >= 59`,
which the outer `runMain` catch wrapped as a SEVERE
"Exception Thrown" message, hiding the real error.
The downstream slicing already clamps via `Math.min(...,
data.length)`, so those requires were over-strict, not
load-bearing. Removed them with a comment explaining the
boundary condition.
After the fix, a missing-brace input produces a normal
Error with file location, e.g.:
[error] badEntity.riddl(5:1->6:2):
Expected one of ("..." | "}" | ...)
Regression test added at `TopLevelParserTest`. Fixture files
`language/input/riddl-bad/{badDomain,badEntity}.riddl` are
checked in (3 opens, 2 closes). Test asserts no Severe and
that the resulting Error mentions the file and lists `}` in
the expected-tokens set.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a89daa6 commit 219c6ac
4 files changed
Lines changed: 48 additions & 2 deletions
File tree
- language
- input/riddl-bad
- jvm-native/src/test/scala/com/ossuminc/riddl/language/parsing
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
150 | 184 | | |
151 | 185 | | |
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
| |||
0 commit comments