Files
Nim/tests/macros/t8997.nim
2019-02-06 22:31:36 -06:00

27 lines
528 B
Nim

discard """
errormsg: "illformed AST: "
line: 24
"""
import macros
type
Node* = ref object
children: seq[Node]
proc newNode*(): Node =
Node(children: newSeq[Node]())
macro build*(body: untyped): untyped =
template appendElement(tmp, childrenBlock) {.dirty.} =
bind newNode
let tmp = newNode()
tmp.children = childrenBlock # this line seems to be the problem
let tmp = genSym(nskLet, "tmp")
let childrenBlock = newEmptyNode()
result = getAst(appendElement(tmp, childrenBlock))
build(body)