From f6bad6f43f7fc5a5da94b1c9d38b52ae3e0b26db Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Fri, 13 Nov 2020 18:57:56 +0800 Subject: [PATCH] close #2771(add testcase for #2771) (#15932) --- tests/iter/t2771.nim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/iter/t2771.nim diff --git a/tests/iter/t2771.nim b/tests/iter/t2771.nim new file mode 100644 index 0000000000000..49befb0a973f5 --- /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