summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2023-08-11 19:11:47 +0800
committerGitHub <noreply@github.com>2023-08-11 19:11:47 +0800
commit277393d0f1c06c422afb6fae581069960609b730 (patch)
tree75f3ad41c63c2f201a4da98e7f6e6ed7ee89f700 /tests
parent3bb75f2dea1c65ee6b4b7fdca48748c97088cf76 (diff)
downloadNim-277393d0f1c06c422afb6fae581069960609b730.tar.gz
close #17045;Compiler crash when a tuple iterator with when nimvm is … (#22452)
close #17045;Compiler crash when a tuple iterator with when nimvm is iterated in a closure iterator
Diffstat (limited to 'tests')
-rw-r--r--tests/async/t17045.nim28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/async/t17045.nim b/tests/async/t17045.nim
new file mode 100644
index 000000000..2b5acf48a
--- /dev/null
+++ b/tests/async/t17045.nim
@@ -0,0 +1,28 @@
+discard """
+  targets: "c cpp"
+  matrix: "--mm:refc; --mm:arc"
+"""
+
+type Future = ref object
+
+iterator paths: string = 
+  # without "when nimvm" everything works
+  when nimvm:
+    yield "test.md"
+  else:
+    yield "test.md"
+
+template await(f: Future): string =
+  # need this yield, also the template has to return something
+  yield f
+  "hello world"
+
+proc generatePostContextsAsync() =
+  iterator generatePostContextsAsyncIter(): Future {.closure.} =
+    for filePath in paths():
+      var temp = await Future()
+
+  # need this line
+  var nameIterVar = generatePostContextsAsyncIter
+
+generatePostContextsAsync()
\ No newline at end of file