fix #14846; add macros.extractDocCommentsAndRunnables (#14849)

* fix #14846; add macros.extractDocCommentsAndRunnables

* fixup

* update tests

* address comment
This commit is contained in:
Timothee Cour 2020-07-01 00:26:23 -07:00 • committed by GitHub
commit 2867a33ebc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 3 deletions

View file

@ -180,8 +180,7 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
# Extract the documentation comment from the original procedure declaration.
# Note that we're not removing it from the body in order not to make this
# transformation even more complex.
if prc.body.len > 1 and prc.body[0].kind == nnkCommentStmt:
outerProcBody.add(prc.body[0])
let body2 = extractDocCommentsAndRunnables(prc.body)
# -> var retFuture = newFuture[T]()
var retFutureSym = genSym(nskVar, "retFuture")
@ -276,9 +275,10 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
(cast[type(f)](internalTmpFuture)).read()
if procBody.kind != nnkEmpty:
result.body = quote:
body2.add quote do:
`awaitDefinition`
`outerProcBody`
result.body = body2
#echo(treeRepr(result))
#if prcName == "recvLineInto":