diff --git a/chronos/asyncloop.nim b/chronos/asyncloop.nim index 3ae42d4..98d23a8 100644 --- a/chronos/asyncloop.nim +++ b/chronos/asyncloop.nim @@ -10,8 +10,6 @@ {.push raises: [Defect].} -include "system/inclrtl" - import std/[os, tables, strutils, heapqueue, lists, options, nativesockets, net, deques] import ./timer @@ -1073,12 +1071,8 @@ proc wait*[T](fut: Future[T], timeout = -1): Future[T] {. else: wait(fut, timeout.milliseconds()) -{.pop.} - include asyncmacro2 -{.push raises: [Defect].} - proc runForever*() {.raises: [Defect, CatchableError].} = ## Begins a never ending global dispatcher poll loop. ## Raises different exceptions depending on the platform. diff --git a/chronos/asyncmacro2.nim b/chronos/asyncmacro2.nim index 7f6ca46..63b7d8c 100644 --- a/chronos/asyncmacro2.nim +++ b/chronos/asyncmacro2.nim @@ -161,7 +161,7 @@ proc processBody(node, retFutureSym: NimNode, proc getName(node: NimNode): string {.compileTime.} = case node.kind of nnkSym: - return $node + return node.strVal of nnkPostfix: return node[1].strVal of nnkIdent: @@ -184,8 +184,7 @@ proc isInvalidReturnType(typeName: string): bool = proc verifyReturnType(typeName: string) {.compileTime.} = if typeName.isInvalidReturnType: - error("Expected return type of 'Future' got '$1'" % - typeName) + error("Expected return type of 'Future' got '" & typeName & "'") macro unsupported(s: static[string]): untyped = error s @@ -309,7 +308,7 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} = )) # If proc has an explicit gcsafe pragma, we add it to iterator as well. - if prc.pragma.findChild(it.kind in {nnkSym, nnkIdent} and $it == "gcsafe") != nil: + if prc.pragma.findChild(it.kind in {nnkSym, nnkIdent} and it.strVal == "gcsafe") != nil: closureIterator.addPragma(newIdentNode("gcsafe")) outerProcBody.add(closureIterator) @@ -335,7 +334,10 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} = # Add discardable pragma. if returnType.kind == nnkEmpty: # Add Future[void] - result.params[0] = parseExpr("Future[void]") + result.params[0] = + newNimNode(nnkBracketExpr, prc) + .add(newIdentNode("Future")) + .add(newIdentNode("void")) if procBody.kind != nnkEmpty: result.body = outerProcBody #echo(treeRepr(result))