summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2020-07-14 18:38:45 +0200
committerClyybber <darkmine956@gmail.com>2020-07-14 19:50:42 +0200
commit695a537c054c5b4e2d8d50e349bef3dfdf15800e (patch)
treecca5de64494b00c9c07df33093add3a27cd622f1
parent03b0374e5cec82146ead8468db0826c287378a13 (diff)
downloadNim-695a537c054c5b4e2d8d50e349bef3dfdf15800e.tar.gz
Closes #13253
-rw-r--r--tests/macros/tmacros_issues.nim31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/macros/tmacros_issues.nim b/tests/macros/tmacros_issues.nim
index 23c9c66c0..255a98ba9 100644
--- a/tests/macros/tmacros_issues.nim
+++ b/tests/macros/tmacros_issues.nim
@@ -29,6 +29,12 @@ array[0 .. 100, int]
 10
 test
 0o377'i8
+1
+2
+3
+foo1
+foo2
+foo3
 '''
 """
 
@@ -258,3 +264,28 @@ macro foobar() =
   echo loopVars
 
 foobar()
+
+
+# bug #13253
+import macros
+
+type
+  FooBar = object
+    a: seq[int]
+
+macro genFoobar(a: static FooBar): untyped =
+  result = newStmtList()
+  for b in a.a:
+    result.add(newCall(bindSym"echo", newLit b))
+
+proc foobar(a: static FooBar) =
+  genFoobar(a)  # removing this make it work
+  for b in a.a:
+    echo "foo" & $b
+
+proc main() =
+  const a: seq[int] = @[1, 2,3]
+  # Error: type mismatch: got <array[0..2, int]> but expected 'seq[int]'
+  const fb = Foobar(a: a)
+  foobar(fb)
+main()