summary refs log blame commit diff stats
path: root/tests/macros/t8997.nim
blob: b0622371740df757132bac88b38350c6ec57ad37 (plain) (tree)
1
2
3
           
                             
          






















                                                                     
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)