summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-02-05 17:14:49 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-02-05 17:14:49 +0100
commit072d79511f0daf30bdf4ce4f1957b7c58b2df512 (patch)
tree1e7b3827bcd39654c0ef0915fd39064096f0b98e
parentb15e8124fe62dca5fb91eefadd1fd0de37de5923 (diff)
downloadNim-072d79511f0daf30bdf4ce4f1957b7c58b2df512.tar.gz
fixes #5314
-rw-r--r--compiler/ccgexprs.nim2
-rw-r--r--tests/async/tasync_in_seq_constr.nim17
2 files changed, 18 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index f8b549777..ade2cb41f 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1210,7 +1210,7 @@ proc genSeqConstr(p: BProc, t: PNode, d: var TLoc) =
 
 proc genArrToSeq(p: BProc, t: PNode, d: var TLoc) =
   var elem, a, arr: TLoc
-  if t.kind == nkBracket:
+  if t.sons[1].kind == nkBracket:
     t.sons[1].typ = t.typ
     genSeqConstr(p, t.sons[1], d)
     return
diff --git a/tests/async/tasync_in_seq_constr.nim b/tests/async/tasync_in_seq_constr.nim
new file mode 100644
index 000000000..7d216e352
--- /dev/null
+++ b/tests/async/tasync_in_seq_constr.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''@[1, 2, 3, 4]'''
+"""
+
+# bug #5314
+
+import asyncdispatch
+
+proc bar(): Future[int] {.async.} =
+    await sleepAsync(500)
+    result = 3
+
+proc foo(): Future[seq[int]] {.async.} =
+    await sleepAsync(500)
+    result = @[1, 2, await bar(), 4] # <--- The bug is here
+
+echo waitFor foo()