Reject assignments with nkEmpty RHS (#9000)

Fixes #8997
This commit is contained in:
LemonBoy 2019-02-06 21:26:55 +01:00 • committed by Andreas Rumpf
commit 294b2e03b2
2 changed files with 35 additions and 7 deletions

26
tests/macros/t8997.nim Normal file
View file

@ -0,0 +1,26 @@
discard """
line: 24
errormsg: "illformed AST: "
"""
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)