Add test for nested finally transform issue (#295)

This commit is contained in:
Tanguy 2022-07-18 23:30:27 +02:00 committed by GitHub
parent 2a19e4ca4c
commit 41b82cdea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -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