summary refs log tree commit diff stats
path: root/lib/pure/asyncmacro.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-03-31 21:14:05 +0200
committerGitHub <noreply@github.com>2020-03-31 21:14:05 +0200
commit9134bb9cfb81297d00ccd6d41fe975e853fca2e5 (patch)
tree7477f7d63057de8cb8912ea1741243f43a5ca4f4 /lib/pure/asyncmacro.nim
parent40898871a9bde4353edc21423b0e8bfe03f68414 (diff)
downloadNim-9134bb9cfb81297d00ccd6d41fe975e853fca2e5.tar.gz
macros for proc types, macros for types (#13778)
* new minor feature: macros for proc types, to be documented

* Finished the implementation and added tests

* [skip ci] Describe the new custom pragmas in the manual and the changelog

Co-authored-by: Zahary Karadjov <zahary@gmail.com>
Diffstat (limited to 'lib/pure/asyncmacro.nim')
-rw-r--r--lib/pure/asyncmacro.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim
index ce84491eb..c6f4ae04a 100644
--- a/lib/pure/asyncmacro.nim
+++ b/lib/pure/asyncmacro.nim
@@ -212,6 +212,12 @@ proc verifyReturnType(typeName: string) {.compileTime.} =
 proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
   ## This macro transforms a single procedure into a closure iterator.
   ## The ``async`` macro supports a stmtList holding multiple async procedures.
+  if prc.kind == nnkProcTy:
+    result = prc
+    if prc[0][0].kind == nnkEmpty:
+      result[0][0] = parseExpr("Future[void]")
+    return result
+
   if prc.kind notin {nnkProcDef, nnkLambda, nnkMethodDef, nnkDo}:
     error("Cannot transform this node kind into an async proc." &
           " proc/method definition or lambda node expected.")