This commit is contained in:
Andreas Rumpf
2016-08-26 13:51:58 +02:00
parent 969981c1da
commit 4d4a993e7f

View File

@@ -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 -----------------------------------------------