summary refs log tree commit diff stats
path: root/tests/effects/tgcsafe3.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/effects/tgcsafe3.nim')
-rw-r--r--tests/effects/tgcsafe3.nim21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/effects/tgcsafe3.nim b/tests/effects/tgcsafe3.nim
new file mode 100644
index 000000000..36ea5112c
--- /dev/null
+++ b/tests/effects/tgcsafe3.nim
@@ -0,0 +1,21 @@
+discard """
+  errormsg: "'myproc' is not GC-safe as it calls 'global_proc'"
+  line: 12
+  cmd: "nim $target --hints:on --threads:on $options $file"
+"""
+
+var useGcMem = "string here"
+
+var global_proc: proc(a: string) {.nimcall.} = proc (a: string) =
+  echo useGcMem
+
+proc myproc(i: int) {.gcsafe.} =
+  when false:
+    if global_proc != nil:
+      echo "a"
+    if isNil(global_proc):
+      return
+
+  global_proc("ho")
+
+myproc(0)