close #7792 by adding a test
This commit is contained in:
parent
a8939686a1
commit
6f5eba4b94
1 changed files with 36 additions and 0 deletions
36
tests/macros/tmacro7.nim
Normal file
36
tests/macros/tmacro7.nim
Normal 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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue