From 5dfa3fd7fa0b7c3f6e7e8bc54a233f8b07d9356c Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 5 Mar 2024 13:53:12 +0100 Subject: [PATCH] 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` --- chronos/internal/raisesfutures.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chronos/internal/raisesfutures.nim b/chronos/internal/raisesfutures.nim index 5b91f415..ed85c036 100644 --- a/chronos/internal/raisesfutures.nim +++ b/chronos/internal/raisesfutures.nim @@ -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()