status-im / nim-chronos

Chronos - An efficient library for asynchronous programming
https://status-im.github.io/nim-chronos/docs/chronos
Apache License 2.0
352 stars 51 forks source link

fix conversion error with `or` on futures with `{.async: (raises: []).}` #514

Closed etan-status closed 3 months ago

etan-status commented 3 months ago
import chronos

proc f(): Future[void] {.async: (raises: []).} =
  discard

discard f() or f() or f()
/Users/etan/Documents/Repos/nimbus-eth2/vendor/nim-chronos/chronos/internal/raisesfutures.nim(145, 44) union
/Users/etan/Documents/Repos/nimbus-eth2/vendor/nimbus-build-system/vendor/Nim/lib/core/macros.nim(185, 28) []
/Users/etan/Documents/Repos/nimbus-eth2/test.nim(6, 13) template/generic instantiation of `or` from here
/Users/etan/Documents/Repos/nimbus-eth2/vendor/nim-chronos/chronos/internal/asyncfutures.nim(1668, 39) template/generic instantiation of `union` from here
/Users/etan/Documents/Repos/nimbus-eth2/vendor/nimbus-build-system/vendor/Nim/lib/core/macros.nim(185, 28) Error: illegal conversion from '-1' to '[0..9223372036854775807]'

Fix by checking for void before trying to access raises

etan-status commented 3 months ago

Somehow, this PR has a prior version of the commit that's on the branch.

As in, what's listed in commits tab is not the same as what/dev/etan/or-void source branch is pointing to.