summary refs log tree commit diff stats
path: root/tests/concepts/tmodifiersinplace.nim
blob: db5583929bf1b7a21f121481b7fe1b474cd74edc (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
27
28
29
30
type
  VarContainer[T] = concept c
    put(var c, T)

  AltVarContainer[T] = concept var c
    put(c, T)

  NonVarContainer[T] = concept c
    put(c, T)

  GoodContainer = object
    x: int

  BadContainer = object
    x: int

proc put(x: BadContainer, y: int) = discard
proc put(x: var GoodContainer, y: int) = discard

template ok(x) = assert(x)
template no(x) = assert(not(x))

static:
  ok GoodContainer is VarContainer[int]
  ok GoodContainer is AltVarContainer[int]
  no BadContainer is VarContainer[int]
  no BadContainer is AltVarContainer[int]
  ok GoodContainer is NonVarContainer[int]
  ok BadContainer is NonVarContainer[int]