t8997.nim 528 B

123456789101112131415161718192021222324252627
  1. discard """
  2. errormsg: "illformed AST: "
  3. line: 24
  4. """
  5. import macros
  6. type
  7. Node* = ref object
  8. children: seq[Node]
  9. proc newNode*(): Node =
  10. Node(children: newSeq[Node]())
  11. macro build*(body: untyped): untyped =
  12. template appendElement(tmp, childrenBlock) {.dirty.} =
  13. bind newNode
  14. let tmp = newNode()
  15. tmp.children = childrenBlock # this line seems to be the problem
  16. let tmp = genSym(nskLet, "tmp")
  17. let childrenBlock = newEmptyNode()
  18. result = getAst(appendElement(tmp, childrenBlock))
  19. build(body)