summary refs log blame commit diff stats
path: root/tests/parallel/tguard2.nim
blob: b69ea33717b4fb1f570e3c6e24cd10063ba75550 (plain) (tree)


























                                   
discard """
  errormsg: "unguarded access: c.i"
  line: 25
"""

type
  ProtectedCounter[T] = object
    i {.guard: L.}: T
    L: int

var
  c: ProtectedCounter[int]

c.i = 89

template atomicRead(L, x): expr =
  {.locks: [L].}:
    x

proc main =
  {.locks: [c.L].}:
    inc c.i
    discard
  echo(atomicRead(c.L, c.i))
  echo c.i

main()