summary refs log tree commit diff stats
path: root/tests/effects/tgcsafe.nim
blob: 363624f19566b5fb31524e87df688bac539a2bf7 (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 """
  errormsg: "'mainUnsafe' is not GC-safe"
  line: 26
  cmd: "nim $target --hints:on --threads:on $options $file"
"""

# bug #6955
var global_proc: proc(a: string): int {.nimcall.} = nil

proc myproc(i: int) {.gcsafe.} =
  if global_proc != nil:
    echo "a"
  if isNil(global_proc):
    return

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)