Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async finally swallows errors when it contains an await wrapped by try/except #23602

Open
nitely opened this issue May 13, 2024 · 0 comments
Open
Labels
Async Everything related to Nim's async

Comments

@nitely
Copy link
Contributor

nitely commented May 13, 2024

Description

The following code should fail with an AssertionDefect error, but it does not.

import std/asyncdispatch

proc errval {.async.} =
  raise newException(ValueError, "err")
  
proc err {.async.} =
  try:
    doAssert false
  finally:
    echo "finally"
    # removing the following code will propagate the AssertionDefect
    try:
      await errval()
    except ValueError:
      echo "valueError"

proc main {.async.} =
  let errFut = err()
  await errFut

waitFor main()

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-05-11
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: c91b33a
active boot switches: -d:release

Current Output

finally
valueError

Expected Output

finally
valueError
[AssertionDefect]

Possible Solution

No response

Additional Information

No response

@juancarlospaco juancarlospaco added the Async Everything related to Nim's async label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Async Everything related to Nim's async
Projects
None yet
Development

No branches or pull requests

2 participants