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

```nim
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`
This commit is contained in:
Etan Kissling 2024-03-05 13:53:12 +01:00 committed by GitHub
parent 7b02247ce7
commit 5dfa3fd7fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -142,7 +142,7 @@ macro union*(tup0: typedesc, tup1: typedesc): typedesc =
if not found:
result.add err
for err2 in getType(getTypeInst(tup1)[1])[1..^1]:
for err2 in tup1.members():
result.add err2
if result.len == 0:
result = makeNoRaises()