summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/asyncmacro.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/pure/asyncmacro.nim b/lib/pure/asyncmacro.nim
index cbed6372c..621a4b00c 100644
--- a/lib/pure/asyncmacro.nim
+++ b/lib/pure/asyncmacro.nim
@@ -207,6 +207,9 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
                                     futureVarIdents)
   # don't do anything with forward bodies (empty)
   if procBody.kind != nnkEmpty:
+    # fix #13899, defer should not escape its original scope
+    procBody = newStmtList(newTree(nnkBlockStmt, newEmptyNode(), procBody))
+
     procBody.add(createFutureVarCompletions(futureVarIdents, nil))
 
     if not subtypeIsVoid: