errormsg: "'horrible' is not GC-safe"
cmd: "nim $target --hints:on --threads:on $options $file"
C:\Nim\tests\threads>nim c --hints:on --threads:on tthreadheapviolation1.nim
Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]
Hint: used config file 'c:\nim\tests\threads\nim.cfg' [Conf]
Hint: system [Processing]
Hint: tthreadheapviolation1 [Processing]
tthreadheapviolation1.nim(14, 7) Hint: 'mydata' is declared but not used [XDeclaredButNotUsed]
tthreadheapviolation1.nim(11, 6) Error: 'horrible' is not GC-safe as it accesses 'global' which is a global using GC'ed memory
Most test files have a so called "spec section" describing the expected output of the compiler and the resulting program. In this case the spec is:
discard """
line: 11
errormsg: "'horrible' is not GC-safe"
cmd: "nim $target --hints:on --threads:on $options $file"
"""
This test ensures the compiler properly reports wrong threading.