make '..' work better with mixed integer types for backwards compat

This commit is contained in:
Andreas Rumpf 2017-11-18 23:51:54 +01:00
commit e96189c9c3

View file

@ -2025,19 +2025,19 @@ when defined(nimNewRoof):
yield res yield res
inc(res) inc(res)
iterator `..`*(a, b: int64): int64 {.inline.} = template dotdotImpl(t) {.dirty.} =
## A special version of ``..`` for ``int64`` only. iterator `..`*(a, b: t): t {.inline.} =
var res = a ## A type specialized version of ``..`` for convenience so that
while res <= b: ## mixing integer types work better.
yield res var res = a
inc(res) while res <= b:
yield res
inc(res)
iterator `..`*(a, b: int32): int32 {.inline.} = dotdotImpl(int64)
## A special version of ``..`` for ``int32`` only. dotdotImpl(int32)
var res = a dotdotImpl(uint64)
while res <= b: dotdotImpl(uint32)
yield res
inc(res)
else: else:
iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} = iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} =