parent
63af8ae53c
commit
ec5cef13cf
2 changed files with 40 additions and 1 deletions
|
|
@ -1115,10 +1115,10 @@ proc genTryGoto(p: BProc; t: PNode; d: var TLoc) =
|
||||||
# 3. finally is run for exception handling code without any 'except'
|
# 3. finally is run for exception handling code without any 'except'
|
||||||
# handler present or only handlers that did not match.
|
# handler present or only handlers that did not match.
|
||||||
linefmt(p, cpsStmts, "*nimErr_ += oldNimErr$1_ + (*nimErr_ - oldNimErrFin$1_); oldNimErr$1_ = 0;$n", [lab])
|
linefmt(p, cpsStmts, "*nimErr_ += oldNimErr$1_ + (*nimErr_ - oldNimErrFin$1_); oldNimErr$1_ = 0;$n", [lab])
|
||||||
raiseExit(p)
|
|
||||||
endBlock(p)
|
endBlock(p)
|
||||||
# restore the real error value:
|
# restore the real error value:
|
||||||
linefmt(p, cpsStmts, "*nimErr_ += oldNimErr$1_;$n", [lab])
|
linefmt(p, cpsStmts, "*nimErr_ += oldNimErr$1_;$n", [lab])
|
||||||
|
if p.prc != nil: raiseExit(p)
|
||||||
|
|
||||||
proc genTrySetjmp(p: BProc, t: PNode, d: var TLoc) =
|
proc genTrySetjmp(p: BProc, t: PNode, d: var TLoc) =
|
||||||
# code to generate:
|
# code to generate:
|
||||||
|
|
|
||||||
39
tests/destructor/tgotoexceptions5.nim
Normal file
39
tests/destructor/tgotoexceptions5.nim
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
discard """
|
||||||
|
output: '''
|
||||||
|
before
|
||||||
|
swallowed
|
||||||
|
before
|
||||||
|
swallowed B
|
||||||
|
'''
|
||||||
|
cmd: "nim c --gc:arc --exceptions:goto $file"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #13599
|
||||||
|
proc main() =
|
||||||
|
try:
|
||||||
|
echo "before"
|
||||||
|
raise newException(CatchableError, "foo")
|
||||||
|
except AssertionError:
|
||||||
|
echo "caught"
|
||||||
|
echo "after"
|
||||||
|
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except:
|
||||||
|
echo "swallowed"
|
||||||
|
|
||||||
|
proc mainB() =
|
||||||
|
try:
|
||||||
|
echo "before"
|
||||||
|
raise newException(CatchableError, "foo")
|
||||||
|
# except CatchableError: # would work
|
||||||
|
except AssertionError:
|
||||||
|
echo "caught"
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
echo "after"
|
||||||
|
|
||||||
|
try:
|
||||||
|
mainB()
|
||||||
|
except:
|
||||||
|
echo "swallowed B"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue