t2771.nim 380 B

12345678910111213141516171819202122
  1. template t1(i: int): int=
  2. i+1
  3. template t2(i: int): int=
  4. i+1
  5. doAssert t1(10).t2() == 12
  6. template it1(i: int): iterator(): int =
  7. iterator result(): int {.closure, gensym.} =
  8. yield i+1
  9. result
  10. template it2(iter: iterator(): int): iterator(): int =
  11. iterator result(): int {.closure, gensym.} =
  12. yield iter()+1
  13. result
  14. let x2 = it1(10).it2()
  15. doAssert x2() == 12