From 31ffc8992fb74d61792cfa8a395940eb2b89ab33 Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Mon, 22 Aug 2022 13:54:50 +1000 Subject: [PATCH] Update compile time check to use when --- ethers/events.nim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ethers/events.nim b/ethers/events.nim index 7cd88ef..626048c 100644 --- a/ethers/events.nim +++ b/ethers/events.nim @@ -35,11 +35,15 @@ func decode*[E: Event](decoder: var AbiDecoder, _: type E): ?!E = success event func isSupported(T: type): bool = - var supported = T is ValueType or - T is SmallByteArray - when compiles (T.distinctBase): - supported = supported or T.distinctBase is ValueType or - T.distinctBase is SmallByteArray + var supported = false + # nim 1.2.x fails distinctBase checks on non-distinct types at compile time, + # so we must separate with `when` + when T is distinct: + supported = T.distinctBase is ValueType or + T.distinctBase is SmallByteArray + else: + supported = T is ValueType or + T is SmallByteArray return supported func decode*[E: Event](_: type E, data: seq[byte], topics: seq[Topic]): ?!E =