summary refs log tree commit diff stats
path: root/tests/async/tasync_in_seq_constr.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/async/tasync_in_seq_constr.nim')
-rw-r--r--tests/async/tasync_in_seq_constr.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/async/tasync_in_seq_constr.nim b/tests/async/tasync_in_seq_constr.nim
new file mode 100644
index 000000000..3d6dae245
--- /dev/null
+++ b/tests/async/tasync_in_seq_constr.nim
@@ -0,0 +1,25 @@
+discard """
+  output: '''
+@[1, 2, 3, 4]
+123
+'''
+"""
+
+# bug #5314, bug #6626
+
+import asyncdispatch
+
+proc bar(i: int): Future[int] {.async.} =
+    await sleepAsync(2)
+    result = i
+
+proc foo(): Future[seq[int]] {.async.} =
+    await sleepAsync(2)
+    result = @[1, 2, await bar(3), 4] # <--- The bug is here
+
+proc foo2() {.async.} =
+    await sleepAsync(2)
+    echo(await bar(1), await bar(2), await bar(3))
+
+echo waitFor foo()
+waitFor foo2()