summary refs log tree commit diff stats
path: root/tests/effects
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-03-05 19:54:44 +0100
committerGitHub <noreply@github.com>2019-03-05 19:54:44 +0100
commitc86b1fbcac11520380ad15e103a8ec429228d735 (patch)
tree99630c61a0c9648eb6a116da65a78b5cc77d119d /tests/effects
parentaed8766e84364360e0ed1e1e667ee735afd99e81 (diff)
downloadNim-c86b1fbcac11520380ad15e103a8ec429228d735.tar.gz
fixes a critical GC safety inference bug (#10615)
* fixes a critical GC safety inference bug
* make nimsuggest compile again
* make Nimble compile again
Diffstat (limited to 'tests/effects')
-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..5137efe4c
--- /dev/null
+++ b/tests/effects/tgcsafe3.nim
@@ -0,0 +1,21 @@
+discard """
+  errormsg: "'myproc' is not GC-safe as it accesses 'global_proc' which is a global using GC'ed memory"
+  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)