diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-08-26 13:51:58 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-08-26 13:51:58 +0200 |
commit | 4d4a993e7f47354b3de80c3f307a7a8d2b50e99b (patch) | |
tree | c4f05a6d7cf2e1ce64675ab7ee3edcb71456effc | |
parent | 969981c1da0e07d9d6867609a335c625779c04c3 (diff) | |
download | Nim-4d4a993e7f47354b3de80c3f307a7a8d2b50e99b.tar.gz |
fixes #2865
-rw-r--r-- | compiler/types.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/types.nim b/compiler/types.nim index ca2718ed1..c06e906e5 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 ----------------------------------------------- |