Files
Nim/tests/parallel/tguard2.nim
2017-07-25 09:28:23 +02:00

28 lines
342 B
Nim

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): untyped =
{.locks: [L].}:
x
proc main =
{.locks: [c.L].}:
inc c.i
discard
echo(atomicRead(c.L, c.i))
echo c.i
main()