mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
27 lines
528 B
Nim
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)
|