Commit cd313fb
committed
Make error reporting resilient to exception thrown while reporting
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.1 parent 926e6a3 commit cd313fb
File tree
3 files changed
+18
-2
lines changed- compiler
- src/dotty/tools/dotc/reporting
- test/dotty/tools/dotc/reporting
- tests/neg
3 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | | - | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| |||
| 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