This commit is contained in:
Andreas Rumpf 2021-07-27 14:32:56 +02:00 • committed by GitHub
commit 6dc34757b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -0,0 +1,26 @@
discard """
outputsub: '''inside closure
hello world'''
cmd: "nim c --gc:orc -d:useMalloc $file"
valgrind: true
"""
# bug #18579
var fp: proc (env: pointer) {.cdecl.}
var env: pointer
proc store(f: proc (){.closure.}) =
proc closeOver() =
echo "inside closure"
f()
(fp,env) = (cast[proc(env: pointer){.cdecl.}](rawProc closeOver), rawEnv closeOver)
GC_ref(cast[RootRef](env))
proc run() =
fp(env)
GC_unref(cast[RootRef](env))
store(proc() = echo "hello world")
run()
GC_fullCollect()