summary refs log tree commit diff stats
path: root/tests/iter
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2023-08-27 20:29:24 +0800
committerGitHub <noreply@github.com>2023-08-27 14:29:24 +0200
commit0b78b7f595ef96a9769e0d59167239c611b9857a (patch)
tree0536d012959891cd3d7a745cc247441d517a8a83 /tests/iter
parentc19fd69b693e0e71d8d03812a42c4b8e50c51a3e (diff)
downloadNim-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.nim22
-rw-r--r--tests/iter/t22548.nim21
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")()