diff --git a/chronos/asyncmacro2.nim b/chronos/asyncmacro2.nim index 570d8aa..b970e4d 100644 --- a/chronos/asyncmacro2.nim +++ b/chronos/asyncmacro2.nim @@ -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.}