summary refs log tree commit diff stats
path: root/compiler/prefixmatches.nim
Path not found
sts/compile/tcompiles.nim?h=devel&id=789ba107cf3bcc1a87d896fc7cbfa11e151898c2'>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
# test the new 'compiles' feature:

template supports(opr, x: expr): bool {.immediate.} =
  compiles(opr(x)) or compiles(opr(x, x))

template ok(x: expr): stmt =
  static: assert(x)

template no(x: expr): stmt =
  static: assert(not x)

type
  TObj = object

var
  myObj {.compileTime.}: TObj

ok supports(`==`, myObj)
ok supports(`==`, 45)

no supports(`++`, 34)
ok supports(`not`, true)
ok supports(`+`, 34)

no compiles(4+5.0 * "hallo")