summary refs log tree commit diff stats
path: root/tests/vm/teval1.nim
blob: 0316ea23879905fc2313727558b3e4029c5975fc (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
31
32
33
34
35
36
37
38
39
40
41
42
discard """
nimout: "##"
"""

import macros

proc testProc: string {.compileTime.} =
  result = ""
  result = result & ""

when true:
  macro test(n: untyped): untyped =
    result = newNimNode(nnkStmtList)
    echo "#", testProc(), "#"
  test:
    "hi"

const
  x = testProc()

doAssert x == ""

# bug #1310
static:
  var i, j: set[int8] = {}
  var k = i + j

type
  Obj = object
    x: int

converter toObj(x: int): Obj = Obj(x: x)

# bug #10514
block:
  const
    b: Obj = 42
    bar = [b]

  let i_runtime = 0
  doAssert bar[i_runtime] == b