blob: 82551b7f7db62982905b54763ed1c6c87c7a0703 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()
|