Nim icon indicating copy to clipboard operation
Nim copied to clipboard

async `and` swallows errors

Open nitely opened this issue 1 year ago • 0 comments
trafficstars

Description

The and function seems to only raise errors for the first async proc.

import std/asyncdispatch

proc ok {.async.} =
  discard

proc err {.async.} =
  raise newException(ValueError, "err")

proc main {.async.} =
  try:
    await ok() and err()
  except ValueError:
    echo "err1"
  try:
    await err() and ok()
  except ValueError:
    echo "err2"
  try:
    await ok() and ok() and err()
  except ValueError:
    echo "err3"

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: c91b33aaba4234d8abdf04af102d71b86e285c58 active boot switches: -d:release

Current Output

err2

Expected Output

err1
err2
err3

Possible Solution

No response

Additional Information

No response

nitely avatar May 13 '24 07:05 nitely