diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-24 00:49:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 17:49:40 +0100 |
commit | 7fc0c3dfbf5e27805fa75745acabf5ce2f0af693 (patch) | |
tree | d602d453f67fd92c2e30aa00939ac4ff4e5a5655 | |
parent | ffccdf3c1a91e3a4ac79b209ae4f034ad253d97b (diff) | |
download | Nim-7fc0c3dfbf5e27805fa75745acabf5ce2f0af693.tar.gz |
ref #5617 add lineinfo to complete (#16102)
-rw-r--r-- | lib/pure/asyncmacro.nim | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index a70508736..dd2393a63 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -11,6 +11,13 @@ import macros, strutils, asyncfutures + +# TODO: Ref https://github.com/nim-lang/Nim/issues/5617 +# TODO: Add more line infos +proc newCallWithLineInfo(fromNode: NimNode; theProc: NimNode, args: varargs[NimNode]): NimNode = + result = newCall(theProc, args) + result.copyLineInfo(fromNode) + template createCb(retFutureSym, iteratorNameSym, strName, identName, futureVarCompletions: untyped) = bind finished @@ -52,15 +59,13 @@ proc createFutureVarCompletions(futureVarIdents: seq[NimNode], # Add calls to complete each FutureVar parameter. for ident in futureVarIdents: # Only complete them if they have not been completed already by the user. - # TODO: Once https://github.com/nim-lang/Nim/issues/5617 is fixed. - # TODO: Add line info to the complete() call! # In the meantime, this was really useful for debugging :) #result.add(newCall(newIdentNode("echo"), newStrLitNode(fromNode.lineinfo))) result.add newIfStmt( ( newCall(newIdentNode("not"), newDotExpr(ident, newIdentNode("finished"))), - newCall(newIdentNode("complete"), ident) + newCallWithLineInfo(fromNode, newIdentNode("complete"), ident) ) ) |