From 792dbed57e2f4475cab8dcc72114ea5f844113c9 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 22 Jan 2019 09:41:11 +0100 Subject: [PATCH] Restore the docstring during the .async. transform (#10404) [backport] Fixes #9816 --- lib/pure/asyncmacro.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index b18d20d554..f1e0aa5682 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -245,6 +245,12 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} = var outerProcBody = newNimNode(nnkStmtList, prc.body) + # 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]) + # -> var retFuture = newFuture[T]() var retFutureSym = genSym(nskVar, "retFuture") var subRetType =