mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 21:17:48 +00:00
@@ -397,18 +397,17 @@ proc hasYieldsInExpressions(n: PNode): bool =
|
||||
|
||||
proc exprToStmtList(n: PNode): tuple[s, res: PNode] =
|
||||
assert(n.kind == nkStmtListExpr)
|
||||
|
||||
var parent = n
|
||||
var lastSon = n[^1]
|
||||
|
||||
while lastSon.kind == nkStmtListExpr:
|
||||
parent = lastSon
|
||||
lastSon = lastSon[^1]
|
||||
|
||||
result.s = newNodeI(nkStmtList, n.info)
|
||||
result.s.sons = parent.sons
|
||||
result.s.sons.setLen(result.s.sons.len - 1) # delete last son
|
||||
result.res = lastSon
|
||||
result.s.sons = @[]
|
||||
|
||||
var n = n
|
||||
while n.kind == nkStmtListExpr:
|
||||
result.s.sons.add(n.sons)
|
||||
result.s.sons.setLen(result.s.sons.len - 1) # delete last son
|
||||
n = n[^1]
|
||||
|
||||
result.res = n
|
||||
|
||||
|
||||
proc newEnvVarAsgn(ctx: Ctx, s: PSym, v: PNode): PNode =
|
||||
result = newTree(nkFastAsgn, ctx.newEnvVarAccess(s), v)
|
||||
|
||||
19
tests/async/t7985.nim
Normal file
19
tests/async/t7985.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
discard """
|
||||
file: "t7985.nim"
|
||||
exitcode: 0
|
||||
output: "(value: 1)"
|
||||
"""
|
||||
import json, asyncdispatch
|
||||
|
||||
proc getData(): Future[JsonNode] {.async.} =
|
||||
result = %*{"value": 1}
|
||||
|
||||
type
|
||||
MyData = object
|
||||
value: BiggestInt
|
||||
|
||||
proc main() {.async.} =
|
||||
let data = to(await(getData()), MyData)
|
||||
echo data
|
||||
|
||||
waitFor(main())
|
||||
Reference in New Issue
Block a user