From 2c0bfb34fd5c6891f8dce211c127a4fa19567c2f Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 3 Oct 2018 18:25:25 +0200 Subject: [PATCH] Fix regression w/ templates defined in async proc --- lib/pure/asyncmacro.nim | 2 +- tests/async/ttemplateinasync.nim | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/async/ttemplateinasync.nim diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim index 1a45fdac71..9acd4bd795 100644 --- a/lib/pure/asyncmacro.nim +++ b/lib/pure/asyncmacro.nim @@ -177,7 +177,7 @@ proc processBody(node, retFutureSym: NimNode, var newDiscard = node result.createVar("futureDiscard_" & $toStrLit(node[0][1]), node[0][1], newDiscard[0], newDiscard, node) - of RoutineNodes: + of RoutineNodes-{nnkTemplateDef}: # skip all the nested procedure definitions return else: discard diff --git a/tests/async/ttemplateinasync.nim b/tests/async/ttemplateinasync.nim new file mode 100644 index 0000000000..f4a2da538b --- /dev/null +++ b/tests/async/ttemplateinasync.nim @@ -0,0 +1,11 @@ +discard """ + output: 42 +""" + +import asyncdispatch + +proc foo(): Future[int] {.async.} = + template ret() = return 42 + ret() + +echo (waitFor foo())