Skip to content

Commit

Permalink
fixes #13070
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Jan 10, 2020
1 parent 4ebfd47 commit af7e04d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/system/excpt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ proc raiseExceptionAux(e: sink(ref Exception)) {.nodestroy.} =
# XXX This check should likely also be done in the setjmp case below.
if e != currException:
pushCurrentException(e)
when gotoBasedExceptions:
inc nimInErrorMode
when gotoBasedExceptions:
inc nimInErrorMode
else:
if excHandler != nil:
pushCurrentException(e)
Expand Down
40 changes: 40 additions & 0 deletions tests/destructor/tgotoexceptions4.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
discard """
cmd: "nim c --gc:arc --exceptions:goto $file"
output: '''caught in gun
caught in fun
caughtsome msgMyExcept
in finally
caught1'''
"""

when true:
# bug #13070
type MyExcept = object of CatchableError
proc gun() =
try:
raise newException(MyExcept, "some msg")
except Exception as eab:
echo "caught in gun"
raise eab

proc fun() =
try:
gun()
except Exception as e:
echo "caught in fun"
echo("caught", e.msg, e.name)
finally:
echo "in finally"
fun()

when true:
# bug #13072
type MyExceptB = object of CatchableError
proc gunB() =
raise newException(MyExceptB, "some msg")
proc funB() =
try:
gunB()
except CatchableError:
echo "caught1"
funB()

0 comments on commit af7e04d

Please sign in to comment.