summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-10-03 19:20:33 +0200
committerGitHub <noreply@github.com>2018-10-03 19:20:33 +0200
commit6e09f40c4e96aadf58e7302c9b09ad17f3b83a37 (patch)
tree4a368e2d04f2dc82efa1bc4184d6bde92f5bcfc1
parent91c13a0163c692dd709eed1b0cf7eee0c19d0f96 (diff)
parent2c0bfb34fd5c6891f8dce211c127a4fa19567c2f (diff)
downloadNim-6e09f40c4e96aadf58e7302c9b09ad17f3b83a37.tar.gz
Merge pull request #9167 from LemonBoy/fix-asyncmacro-regression
Fix regression w/ templates defined in async proc
-rw-r--r--lib/pure/asyncmacro.nim2
-rw-r--r--tests/async/ttemplateinasync.nim11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim
index 1a45fdac7..9acd4bd79 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 000000000..f4a2da538
--- /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())