diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-07-10 16:31:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 10:31:13 +0200 |
commit | ecc6ab7ee06a5969fd871585de8b93120bd58a2b (patch) | |
tree | 841478f537c16b6a44ccc6a21a2b31e9e7f528fe /tests/arc | |
parent | 1b132ddaa2734fc43a9c172407fc968cfeec4a24 (diff) | |
download | Nim-ecc6ab7ee06a5969fd871585de8b93120bd58a2b.tar.gz |
fixes #22237; fixes #21160; wrong cursor on unowned parameters in the for loop in ORC (#22240)
fixes #22237; fixes #21160; wrong cursor on unowned parameters
Diffstat (limited to 'tests/arc')
-rw-r--r-- | tests/arc/t22237.nim | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/arc/t22237.nim b/tests/arc/t22237.nim new file mode 100644 index 000000000..c6dbf768a --- /dev/null +++ b/tests/arc/t22237.nim @@ -0,0 +1,55 @@ +discard """ + matrix: "--mm:arc; --mm:orc" +""" + +import std/macros +import std/streams + +# bug #22237 + +proc iterlines_closure2(f: File | Stream): iterator (): string = + result = iterator(): string = + for line in f.lines: + if line.len == 0: + break + yield line + +proc test() = + let f = newStringStream(""" + 1 + 2 + + 3 + 4 + + 5 + 6 + 7 + + 8 +""") + while not f.atEnd(): + let iterator_inst = iterlines_closure2(f) + for item in iterator_inst(): # Fails with "SIGSEGV: Illegal storage access. (Attempt to read from nil?)" + discard + +test() + +# bug #21160 +import sequtils + +iterator allMoves(fls: seq[int]): seq[int] = + yield fls + +proc neighbors(flrs: seq[int]): iterator: seq[int] = + return iterator(): seq[int] = + for flrs2 in allMoves(flrs): + yield flrs2 + for flrs3 in allMoves(flrs2): + yield flrs3 + +let f = @[1] +for _ in neighbors(f): + discard +for _ in neighbors(f): + discard |