t11042.nim 689 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. discard """
  2. output:'''
  3. foo: 1
  4. foo: 2
  5. bar: 1
  6. bar: 2
  7. foo: 1
  8. foo: 2
  9. bar: 1
  10. bar: 2
  11. bar: 3
  12. bar: 4
  13. bar: 5
  14. bar: 6
  15. bar: 7
  16. bar: 8
  17. bar: 9
  18. '''
  19. """
  20. # bug #11042
  21. block:
  22. iterator foo: int =
  23. for x in 1..2:
  24. echo "foo: ", x
  25. for y in 1..2:
  26. discard
  27. for x in foo(): discard
  28. let bar = iterator: int =
  29. for x in 1..2:
  30. echo "bar: ", x
  31. for y in 1..2:
  32. discard
  33. for x in bar(): discard
  34. block:
  35. iterator foo: int =
  36. for x in 1..2:
  37. echo "foo: ", x
  38. for y in 1..2:
  39. discard
  40. for x in foo(): discard
  41. let bar = iterator: int =
  42. for x in 1..9:
  43. echo "bar: ", x
  44. for y in 1..2:
  45. discard
  46. for x in bar(): discard