From 41b82cdea34744148600b67a9154331b76181189 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Mon, 18 Jul 2022 23:30:27 +0200 Subject: [PATCH] Add test for nested finally transform issue (#295) --- tests/testmacro.nim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testmacro.nim b/tests/testmacro.nim index 705ec2d..f834ce3 100644 --- a/tests/testmacro.nim +++ b/tests/testmacro.nim @@ -104,3 +104,20 @@ suite "Macro transformations test suite": macroAsync2(testMacro2, seq, Opt, Result, OpenObject, cstring) check waitFor(testMacro2()).len == 0 + +suite "async transformation issues": + test "Nested defer/finally not called on return": + # issue #288 + # fixed by https://github.com/nim-lang/Nim/pull/19933 + var answer = 0 + proc a {.async.} = + try: + try: + await sleepAsync(0) + return + finally: + answer = 32 + finally: + answer.inc(10) + waitFor(a()) + check answer == 42