rewritten goto based exception handling; much cleaner implementation;… (#13677)

* rewritten goto based exception handling; much cleaner implementation; fixes #13668
This commit is contained in:
Andreas Rumpf 2020-03-17 23:18:43 +01:00 • committed by GitHub
commit fe7b1dfb2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 26 deletions

View file

@ -420,16 +420,16 @@ proc nimLeaveFinally() {.compilerRtl.} =
quit(1)
when gotoBasedExceptions:
var nimInErrorMode {.threadvar.}: int
var nimInErrorMode {.threadvar.}: bool
proc nimErrorFlag(): ptr int {.compilerRtl, inl.} =
proc nimErrorFlag(): ptr bool {.compilerRtl, inl.} =
result = addr(nimInErrorMode)
proc nimTestErrorFlag() {.compilerRtl.} =
## This proc must be called before ``currException`` is destroyed.
## It also must be called at the end of every thread to ensure no
## error is swallowed.
if currException != nil:
if nimInErrorMode and currException != nil:
reportUnhandledError(currException)
currException = nil
quit(1)