From 072d79511f0daf30bdf4ce4f1957b7c58b2df512 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 5 Feb 2017 17:14:49 +0100 Subject: [PATCH] fixes #5314 --- compiler/ccgexprs.nim | 2 +- tests/async/tasync_in_seq_constr.nim | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/async/tasync_in_seq_constr.nim diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index f8b549777d..ade2cb41ff 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 0000000000..7d216e352f --- /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()