t2771.nim 415 B

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