summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-13 18:57:56 +0800
committerGitHub <noreply@github.com>2020-11-13 11:57:56 +0100
commit7d51ad96e9add19c45b3c679f30fcb70d7fbe138 (patch)
treeef2420a581f2fbba8216e3d3a766457f5c16bfe2 /tests
parent8a21f94c7263f10c12c62ec2beb736ab8ce183c9 (diff)
downloadNim-7d51ad96e9add19c45b3c679f30fcb70d7fbe138.tar.gz
close #2771(add testcase for #2771) (#15932)
Diffstat (limited to 'tests')
-rw-r--r--tests/iter/t2771.nim21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/iter/t2771.nim b/tests/iter/t2771.nim
new file mode 100644
index 000000000..49befb0a9
--- /dev/null
+++ b/tests/iter/t2771.nim
@@ -0,0 +1,21 @@
+template t1(i: int): int=
+  i+1
+template t2(i: int): int=
+  i+1
+
+doAssert t1(10).t2() == 12
+
+
+template it1(i: int): iterator(): int =
+  iterator result(): int {.closure, gensym.} =
+    yield i+1
+  result
+
+template it2(iter: iterator(): int): iterator(): int =
+  iterator result(): int {.closure, gensym.} =
+    yield iter()+1
+  result
+
+let x2 = it1(10).it2()
+
+doAssert x2() == 12