We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 118c5db commit 32df6c9Copy full SHA for 32df6c9
src/pylib/Lib/random_impl/proc_dispatched.nim
@@ -27,7 +27,10 @@ genGbls:
27
28
func randint*[T: SomeInteger](self; a, b: T): T = rnd.rand(a .. b)
29
30
- func randrange*[T: SomeInteger](self; stop: T): T = rnd.rand stop
+ func randrange*[T: SomeInteger](self; stop: T): T =
31
+ if stop < 1:
32
+ raise newException(ValueError, "empty range for randrange()")
33
+ rnd.rand stop - 1
34
func randrange*[T: SomeInteger](self; start, stop: T): T = rnd.rand start..<stop
35
36
#template randrange*[T: SomeInteger](start, stop: T; step: int): T =
0 commit comments