tgcsafe.nim 560 B

123456789101112131415161718192021222324252627
  1. discard """
  2. errormsg: "'mainUnsafe' is not GC-safe as it performs an indirect call here"
  3. line: 26
  4. cmd: "nim $target --hints:on --threads:on $options $file"
  5. """
  6. # bug #6955
  7. var global_proc: proc(a: string): int {.nimcall.} = nil
  8. proc myproc(i: int) {.gcsafe.} =
  9. if global_proc != nil:
  10. echo "a"
  11. if isNil(global_proc):
  12. return
  13. proc mymap(x: proc ()) {.effectsOf: x.} =
  14. x()
  15. var
  16. myglob: string
  17. proc mainSafe() {.gcsafe.} =
  18. mymap(proc () = echo "foo")
  19. proc mainUnsafe() {.gcsafe.} =
  20. mymap(proc () = myglob = "bar"; echo "foo", myglob)