mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-02-20 23:18:22 +00:00
Disallow waitFor in async
This commit is contained in:
parent
a30e4fe361
commit
bff83a9c3c
@ -188,13 +188,11 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
|
||||
var subRetType =
|
||||
if returnType.kind == nnkEmpty: newIdentNode("void")
|
||||
else: baseType
|
||||
outerProcBody.add(
|
||||
newVarStmt(retFutureSym,
|
||||
newCall(
|
||||
newNimNode(nnkBracketExpr, prc.body).add(
|
||||
newIdentNode("newFuture"),
|
||||
subRetType),
|
||||
newLit(prcName)))) # Get type from return type of this proc
|
||||
outerProcBody.add quote do:
|
||||
var `retFutureSym` = newFuture[`subRetType`](`prcName`)
|
||||
template waitFor[T](f: Future[T]): T =
|
||||
static:
|
||||
assert(false, "waitFor can not be used within {.async.}")
|
||||
|
||||
# -> iterator nameIter(): FutureBase {.closure.} =
|
||||
# -> {.push warning[resultshadowed]: off.}
|
||||
|
Loading…
x
Reference in New Issue
Block a user