summary refs log tree commit diff stats
path: root/tests/vm/tmitems.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vm/tmitems.nim')
-rw-r--r--tests/vm/tmitems.nim31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/vm/tmitems.nim b/tests/vm/tmitems.nim
new file mode 100644
index 000000000..4ee225eed
--- /dev/null
+++ b/tests/vm/tmitems.nim
@@ -0,0 +1,31 @@
+discard """
+  msg: '''13'''
+  output: '''3
+3
+3'''
+"""
+# bug #3731
+var list {.compileTime.} = newSeq[int]()
+
+macro calc*(): stmt {.immediate.} =
+  list.add(1)
+  for c in list.mitems:
+    c = 13
+
+  for c in list:
+    echo c
+
+calc()
+
+# bug #3859
+import macros
+macro m: stmt =
+  var s = newseq[NimNode](3)
+  # var s: array[3,NimNode]                 # not working either
+  for i in 0..<s.len: s[i] = newLit(3)    # works
+  #for x in s.mitems: x = newLit(3)
+  result = newStmtList()
+  for i in s:
+    result.add newCall(bindsym"echo", i)
+
+m()