From 4d4a993e7f47354b3de80c3f307a7a8d2b50e99b Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 26 Aug 2016 13:51:58 +0200 Subject: [PATCH] fixes #2865 --- compiler/types.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/types.nim b/compiler/types.nim index ca2718ed16..c06e906e56 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -653,7 +653,14 @@ proc lengthOrd(t: PType): BiggestInt = case t.kind of tyInt64, tyInt32, tyInt: result = lastOrd(t) of tyDistinct, tyConst, tyMutable: result = lengthOrd(t.sons[0]) - else: result = lastOrd(t) - firstOrd(t) + 1 + else: + let last = lastOrd t + let first = firstOrd t + # XXX use a better overflow check here: + if last == high(BiggestInt) and first <= 0: + result = last + else: + result = lastOrd(t) - firstOrd(t) + 1 # -------------- type equality -----------------------------------------------