Skip to content

Commit

Permalink
Stricter signature for countdown/countup (#8549)
Browse files Browse the repository at this point in the history
  • Loading branch information
GULPF authored and Araq committed Aug 7, 2018
1 parent c3d5ec8 commit 9b9cfa7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ when sizeof(int) <= 2:
else:
type IntLikeForCount = int|int8|int16|int32|char|bool|uint8|uint16|enum

iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} =
## Counts from ordinal value `a` down to `b` (inclusive) with the given
## step count. `T` may be any ordinal type, `step` may only
## be positive. **Note**: This fails to count to ``low(int)`` if T = int for
Expand All @@ -2001,7 +2001,7 @@ iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
dec(res, step)

when defined(nimNewRoof):
iterator countup*[T](a, b: T, step = 1): T {.inline.} =
iterator countup*[T](a, b: T, step: Positive = 1): T {.inline.} =
## Counts from ordinal value `a` up to `b` (inclusive) with the given
## step count. `S`, `T` may be any ordinal type, `step` may only
## be positive. **Note**: This fails to count to ``high(int)`` if T = int for
Expand All @@ -2018,7 +2018,7 @@ when defined(nimNewRoof):
inc(res, step)

iterator `..`*[T](a, b: T): T {.inline.} =
## An alias for `countup`.
## An alias for `countup(a, b, 1)`.
when T is IntLikeForCount:
var res = int(a)
while res <= int(b):
Expand Down

0 comments on commit 9b9cfa7

Please sign in to comment.