From 9134bb9cfb81297d00ccd6d41fe975e853fca2e5 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 31 Mar 2020 21:14:05 +0200 Subject: 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 --- lib/pure/asyncmacro.nim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/pure/asyncmacro.nim') 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.") -- cgit 1.4.1-2-gfad0