diff options
author | Bung <crc32@qq.com> | 2023-08-27 20:29:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-27 14:29:24 +0200 |
commit | 0b78b7f595ef96a9769e0d59167239c611b9857a (patch) | |
tree | 0536d012959891cd3d7a745cc247441d517a8a83 /tests/iter | |
parent | c19fd69b693e0e71d8d03812a42c4b8e50c51a3e (diff) | |
download | Nim-0b78b7f595ef96a9769e0d59167239c611b9857a.tar.gz |
fix #22548;environment misses for type reference in iterator access n… (#22559)
* fix #22548;environment misses for type reference in iterator access nested in closure * fix #21737 * Update lambdalifting.nim * remove containsCallKinds * simplify
Diffstat (limited to 'tests/iter')
-rw-r--r-- | tests/iter/t21737.nim | 22 | ||||
-rw-r--r-- | tests/iter/t22548.nim | 21 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/iter/t21737.nim b/tests/iter/t21737.nim new file mode 100644 index 000000000..da06faea7 --- /dev/null +++ b/tests/iter/t21737.nim @@ -0,0 +1,22 @@ +discard """ + action: compile +""" + +template mytoSeq*(iter: untyped): untyped = + var result: seq[typeof(iter)]# = @[] + for x in iter: + result.add(x) + result + +iterator test(dir:int): int = + yield 1234 + +iterator walkGlobKinds (): int = + let dir2 = 123 + let it = mytoSeq(test(dir2)) + +proc main()= + let it = iterator(): int= + for path in walkGlobKinds(): + yield path +main() diff --git a/tests/iter/t22548.nim b/tests/iter/t22548.nim new file mode 100644 index 000000000..b9abb75d0 --- /dev/null +++ b/tests/iter/t22548.nim @@ -0,0 +1,21 @@ +discard """ + action: compile +""" + +type Xxx[T] = object + +iterator x(v: string): char = + var v2: Xxx[int] + + var y: v2.T + + echo y + +proc bbb(vv: string): proc () = + proc xxx() = + for c in x(vv): + echo c + + return xxx + +bbb("test")() |