tshallowcopy_closures.nim 487 B

123456789101112131415161718192021222324252627282930313233343536
  1. discard """
  2. ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')"
  3. output: '''
  4. a1 10
  5. a1 9
  6. '''
  7. """
  8. # bug #1803
  9. type TaskFn = iterator (): float
  10. iterator a1(): float {.closure.} =
  11. var k = 10
  12. while k > 0:
  13. echo "a1 ", k
  14. dec k
  15. yield 1.0
  16. iterator a2(): float {.closure.} =
  17. var k = 15
  18. while k > 0:
  19. echo "a2 ", k
  20. dec k
  21. yield 2.0
  22. var
  23. x = a1
  24. y = a2
  25. z: TaskFn
  26. discard x()
  27. shallowCopy(z, x)
  28. shallowCopy(z, y)
  29. discard x()