summary refs log tree commit diff stats
path: root/tests/effects/tgcsafe.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/effects/tgcsafe.nim')
-rw-r--r--tests/effects/tgcsafe.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/effects/tgcsafe.nim b/tests/effects/tgcsafe.nim
new file mode 100644
index 000000000..87388238a
--- /dev/null
+++ b/tests/effects/tgcsafe.nim
@@ -0,0 +1,16 @@
+discard """
+  line: 15
+  errormsg: "'mainUnsafe' is not GC-safe"
+"""
+
+proc mymap(x: proc ()) =
+  x()
+
+var
+  myglob: string
+
+proc mainSafe() {.gcsafe.} =
+  mymap(proc () = echo "foo")
+
+proc mainUnsafe() {.gcsafe.} =
+  mymap(proc () = myglob = "bar"; echo "foo", myglob)