newruntime: raising an exception works but currently leaks memory because currentException global is not an 'owned' ref
This commit is contained in:
parent
cb4e04d88e
commit
2846156e13
4 changed files with 60 additions and 6 deletions
38
tests/destructor/tv2_raise.nim
Normal file
38
tests/destructor/tv2_raise.nim
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
discard """
|
||||
cmd: '''nim c --newruntime $file'''
|
||||
output: '''OK 2
|
||||
4 1'''
|
||||
"""
|
||||
|
||||
import strutils, math
|
||||
import system / ansi_c
|
||||
import core / allocators
|
||||
|
||||
proc mainA =
|
||||
var e: owned(ref ValueError)
|
||||
new(e)
|
||||
e.msg = "message"
|
||||
raise e
|
||||
|
||||
proc main =
|
||||
raise newException(ValueError, "argh")
|
||||
|
||||
var ok = 0
|
||||
try:
|
||||
mainA()
|
||||
except ValueError:
|
||||
inc ok
|
||||
except:
|
||||
discard
|
||||
|
||||
try:
|
||||
main()
|
||||
except ValueError:
|
||||
inc ok
|
||||
except:
|
||||
discard
|
||||
|
||||
echo "OK ", ok
|
||||
|
||||
let (a, d) = allocCounters()
|
||||
discard cprintf("%ld %ld\n", a, d)
|
||||
Loading…
Add table
Add a link
Reference in a new issue