diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-07-27 14:32:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 14:32:56 +0200 |
commit | 6dc34757b6ed58aac723b409f084665b26a8afb1 (patch) | |
tree | 1523b96ae3800d1b9816b9877b2296738377684f /tests/arc/tunref_cycle.nim | |
parent | c86f9590fb5ba6512ba33994fa0711341eb8524b (diff) | |
download | Nim-6dc34757b6ed58aac723b409f084665b26a8afb1.tar.gz |
fixes #18579 (#18600)
Diffstat (limited to 'tests/arc/tunref_cycle.nim')
-rw-r--r-- | tests/arc/tunref_cycle.nim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/arc/tunref_cycle.nim b/tests/arc/tunref_cycle.nim new file mode 100644 index 000000000..82551b7f7 --- /dev/null +++ b/tests/arc/tunref_cycle.nim @@ -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() |