mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 07:13:27 +00:00
close #7792 by adding a test
This commit is contained in:
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()
|
||||
Reference in New Issue
Block a user