close #7792 by adding a test

This commit is contained in:
narimiran
2019-05-29 14:56:39 +02:00
parent a8939686a1
commit 6f5eba4b94

36
tests/macros/tmacro7.nim Normal file
View File

@@ -0,0 +1,36 @@
discard """
output: '''calling!stuff
calling!stuff
'''
"""
# issue #7792
import macros
proc callProc(str: string) =
echo "calling!" & str
macro testMacro(code: typed): untyped =
let stmtList = newNimNode(nnkStmtList)
let stmts = code[6]
for n in stmts.children:
# the error happens here
stmtList.add(newCall(bindSym("callProc"), newLit("stuff")))
code[6] = stmtList
result = newEmptyNode()
proc main() {.testMacro.} =
echo "test"
echo "test2"
when isMainModule:
main()