bugfix: finally blocks were not executed when the except block is exited by raise or return

This commit is contained in:
Zahary Karadjov 2012-06-03 18:00:45 +03:00
commit 3ce400bb00
3 changed files with 87 additions and 13 deletions

66
tests/run/texceptions.nim Normal file
View file

@ -0,0 +1,66 @@
discard """
output: '''
BEFORE
FINALLY
BEFORE
EXCEPT
FINALLY
RECOVER
BEFORE
EXCEPT
FINALLY
'''
"""
echo ""
proc no_expcetion =
try:
echo "BEFORE"
except:
echo "EXCEPT"
raise
finally:
echo "FINALLY"
try: no_expcetion()
except: echo "RECOVER"
echo ""
proc reraise_in_except =
try:
echo "BEFORE"
raise newException(EIO, "")
except:
echo "EXCEPT"
raise
finally:
echo "FINALLY"
try: reraise_in_except()
except: echo "RECOVER"
echo ""
proc return_in_except =
try:
echo "BEFORE"
raise newException(EIO, "")
except:
echo "EXCEPT"
return
finally:
echo "FINALLY"
try: return_in_except()
except: echo "RECOVER"