Commit dfff8f6
authored
Make error reporting resilient to exception thrown while reporting (#20158)
Previously the added test failed with `1 error reported` but no actual
error message printed, because a stack overflow is thrown while
reporting the original error. This is then caught and handled to emit a
RecursionOverflow error, but that second error is non-sensical and
non-sensical errors are only printed if `hasErrors` returns false.
We fix this by deferring incrementing the error count (and therefore
having `hasErrors` return true) until after having displayed the error.
We also defer calling `markReported` otherwise the second error will
also be suppressed. A similar change is necessary in our testing
infrastructure to keep the error count is coherent.File tree
3 files changed
+24
-2
lines changed- compiler
- src/dotty/tools/dotc/reporting
- test/dotty/tools/dotc/reporting
- tests/neg
3 files changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
| |||
168 | 175 | | |
169 | 176 | | |
170 | 177 | | |
171 | | - | |
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | 74 | | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments