randomize: added doAssert(seed!=0) to avoid invalid (non-random) behavior (#10635)

This commit is contained in:
Timothee Cour
2019-02-12 00:33:20 -08:00
committed by Andreas Rumpf
parent e3ba2e24cf
commit 304b1dd34b

View File

@@ -513,6 +513,7 @@ proc initRand*(seed: int64): Rand =
let now = getTime()
var r2 = initRand(now.toUnix * 1_000_000_000 + now.nanosecond)
doAssert seed != 0 # 0 causes `rand(int)` to always return 0 for example.
result.a0 = ui(seed shr 16)
result.a1 = ui(seed and 0xffff)
discard next(result)