Better error message for rand(153 .. 102) (#17031)
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
parent
339ebe958d
commit
00f86f5591
1 changed files with 1 additions and 1 deletions
|
|
@ -309,7 +309,7 @@ proc rand*[T: Ordinal or SomeFloat](r: var Rand; x: HSlice[T, T]): T =
|
||||||
doAssert r.rand(1..6) == 4
|
doAssert r.rand(1..6) == 4
|
||||||
doAssert r.rand(1..6) == 6
|
doAssert r.rand(1..6) == 6
|
||||||
let f = r.rand(-1.0 .. 1.0) # 0.8741183448756229
|
let f = r.rand(-1.0 .. 1.0) # 0.8741183448756229
|
||||||
|
assert x.a <= x.b
|
||||||
when T is SomeFloat:
|
when T is SomeFloat:
|
||||||
result = rand(r, x.b - x.a) + x.a
|
result = rand(r, x.b - x.a) + x.a
|
||||||
else: # Integers and Enum types
|
else: # Integers and Enum types
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue