1discard """ 2output: ''' 3calling!stuff 4calling!stuff 5''' 6disabled: true 7""" 8 9# this test modifies an already semchecked ast (bad things happen) 10# this test relies on the bug #4547 11# issue #7792 12 13import macros 14 15proc callProc(str: string) = 16 echo "calling!" & str 17 18macro testMacro(code: typed): untyped = 19 let stmtList = newNimNode(nnkStmtList) 20 21 let stmts = code[6] 22 23 for n in stmts.children: 24 # the error happens here 25 stmtList.add(newCall(bindSym("callProc"), newLit("stuff"))) 26 27 code[6] = stmtList 28 29 result = newEmptyNode() 30 31proc main() {.testMacro.} = 32 echo "test" 33 echo "test2" 34 35when isMainModule: 36 main() 37