summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authornarimiran <narimiran@disroot.org>2019-05-29 14:56:39 +0200
committernarimiran <narimiran@disroot.org>2019-05-29 14:56:39 +0200
commit6f5eba4b9438b38cc29a66feb239a7be0507f762 (patch)
tree60e1216d9935c5a40cb427586987bb744344dbae /tests
parenta8939686a15f966919823bc97c371be60b99aab9 (diff)
downloadNim-6f5eba4b9438b38cc29a66feb239a7be0507f762.tar.gz
close #7792 by adding a test
Diffstat (limited to 'tests')
-rw-r--r--tests/macros/tmacro7.nim36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/macros/tmacro7.nim b/tests/macros/tmacro7.nim
new file mode 100644
index 000000000..682e70d01
--- /dev/null
+++ b/tests/macros/tmacro7.nim
@@ -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()