summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-06-20 10:44:03 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-06-20 10:44:03 +0200
commit1c8a50797a08e7e475087773a95ffaf839bf0bf3 (patch)
treee32357ceec29f767fecbb5996433070e20cce882
parent0fbca73e7140e891df6a5797ee7d7d38563f28da (diff)
parent58eae1171ddce623e44257ea3929969f5099f5db (diff)
downloadNim-1c8a50797a08e7e475087773a95ffaf839bf0bf3.tar.gz
Merge branch 'fix-5995' of https://github.com/yglukhov/Nim into yglukhov-fix-5995
-rw-r--r--compiler/semstmts.nim2
-rw-r--r--lib/pure/asyncmacro.nim2
-rw-r--r--tests/async/tlambda.nim3
3 files changed, 5 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 576f2695b..7ea7763c3 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1129,7 +1129,7 @@ proc semProcAnnotation(c: PContext, prc: PNode;
       x.add(it.sons[1])
     x.add(prc)
     # recursion assures that this works for multiple macro annotations too:
-    result = semStmt(c, x)
+    result = semExpr(c, x)
     # since a proc annotation can set pragmas, we process these here again.
     # This is required for SqueakNim-like export pragmas.
     if result.kind in procDefs and result[namePos].kind == nkSym and
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim
index a104478ac..89b216b25 100644
--- a/lib/pure/asyncmacro.nim
+++ b/lib/pure/asyncmacro.nim
@@ -301,7 +301,7 @@ 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 notin {nnkProcDef, nnkLambda, nnkMethodDef}:
+  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.")
 
diff --git a/tests/async/tlambda.nim b/tests/async/tlambda.nim
index e0ff1f483..d187c0d50 100644
--- a/tests/async/tlambda.nim
+++ b/tests/async/tlambda.nim
@@ -51,5 +51,8 @@ proc main() =
 
   var builder = newBuilder()
 
+  # Test {.async.} pragma with do notation: #5995
+  builder.client = newClient("builder") do(client: Client, msg: JsonNode) {.async.}:
+    await onMessage(builder, msg)
 
 main()