Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yglukhov authored and Araq committed Jul 22, 2018
1 parent 9379f93 commit 2094209
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
2 changes: 1 addition & 1 deletion compiler/closureiters.nim
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
let branch = n[i]
case branch.kind
of nkOfBranch:
branch[1] = ctx.convertExprBodyToAsgn(branch[1], tmp)
branch[^1] = ctx.convertExprBodyToAsgn(branch[^1], tmp)
of nkElse:
branch[0] = ctx.convertExprBodyToAsgn(branch[0], tmp)
else:
Expand Down
15 changes: 0 additions & 15 deletions tests/async/t6100.nim

This file was deleted.

19 changes: 0 additions & 19 deletions tests/async/t7985.nim

This file was deleted.

47 changes: 47 additions & 0 deletions tests/async/tasync_misc.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
discard """
exitcode: 0
output: "ok"
"""

import json, asyncdispatch
block: #6100
let done = newFuture[int]()
done.complete(1)

proc asyncSum: Future[int] {.async.} =
for _ in 1..10_000_000:
result += await done

let res = waitFor asyncSum()
doAssert(res == 10000000)

block: #7985
proc getData(): Future[JsonNode] {.async.} =
result = %*{"value": 1}

type
MyData = object
value: BiggestInt

proc main() {.async.} =
let data = to(await(getData()), MyData)
doAssert($data == "(value: 1)")

waitFor(main())

block: #8399
proc bar(): Future[string] {.async.} = discard

proc foo(line: string) {.async.} =
var res =
case line[0]
of '+', '-': @[]
of '$': (let x = await bar(); @[""])
else:
nil

doAssert(res == @[""])

waitFor foo("$asd")

echo "ok"

0 comments on commit 2094209

Please sign in to comment.