t22237.nim 939 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. discard """
  2. matrix: "--mm:arc; --mm:orc"
  3. """
  4. import std/macros
  5. import std/streams
  6. # bug #22237
  7. proc iterlines_closure2(f: File | Stream): iterator (): string =
  8. result = iterator(): string =
  9. for line in f.lines:
  10. if line.len == 0:
  11. break
  12. yield line
  13. proc test() =
  14. let f = newStringStream("""
  15. 1
  16. 2
  17. 3
  18. 4
  19. 5
  20. 6
  21. 7
  22. 8
  23. """)
  24. while not f.atEnd():
  25. let iterator_inst = iterlines_closure2(f)
  26. for item in iterator_inst(): # Fails with "SIGSEGV: Illegal storage access. (Attempt to read from nil?)"
  27. discard
  28. test()
  29. # bug #21160
  30. import sequtils
  31. iterator allMoves(fls: seq[int]): seq[int] =
  32. yield fls
  33. proc neighbors(flrs: seq[int]): iterator: seq[int] =
  34. return iterator(): seq[int] =
  35. for flrs2 in allMoves(flrs):
  36. yield flrs2
  37. for flrs3 in allMoves(flrs2):
  38. yield flrs3
  39. let f = @[1]
  40. for _ in neighbors(f):
  41. discard
  42. for _ in neighbors(f):
  43. discard