fix #17467 1st call to rand is now non-skewed; allow seed == 0 (#17468)

* fix #17467 1st call to rand is now non-skewed; allow passing 0 as seed

* changelog + fallback

* document behavior for seed == 0

* address comments

* _

* fix tests, disable kdtree

* re-enable kdtree with -d:nimLegacyRandomInitRand
This commit is contained in:
Timothee Cour 2021-05-11 02:04:59 -07:00 • committed by GitHub
commit 45490497e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 67 deletions

View file

@ -63,6 +63,10 @@
- Nim compiler now adds ASCII unit separator `\31` before a newline for every generated
message (potentially multiline), so tooling can tell when messages start and end.
- `random.initRand(seed)` now produces non-skewed values for the 1st call to `rand()` after
initialization with a small (< 30000) seed. Use `-d:nimLegacyRandomInitRand` to restore
previous behavior for a transition time, see PR #17467.
## Standard library additions and changes
- Added support for parenthesized expressions in `strformat`
@ -119,6 +123,13 @@
- Added `randState` template that exposes the default random number generator.
Useful for library authors.
- Added `random.initRand()` overload with no argument which uses the current time as a seed.
- `random.initRand(seed)` now allows `seed == 0`.
- Added `std/sysrand` module to get random numbers from a secure source
provided by the operating system.
- Added `std/enumutils` module. Added `genEnumCaseStmt` macro that generates case statement to parse string to enum.
Added `items` for enums with holes.
Added `symbolName` to return the enum symbol name ignoring the human readable name.
@ -205,9 +216,6 @@
- Deprecated `any`. See https://github.com/nim-lang/RFCs/issues/281
- Added `std/sysrand` module to get random numbers from a secure source
provided by the operating system.
- Added optional `options` argument to `copyFile`, `copyFileToDir`, and
`copyFileWithPermissions`. By default, on non-Windows OSes, symlinks are
followed (copy files symlinks point to); on Windows, `options` argument is
@ -225,8 +233,6 @@
- Added `os.isAdmin` to tell whether the caller's process is a member of the
Administrators local group (on Windows) or a root (on POSIX).
- Added `random.initRand()` overload with no argument which uses the current time as a seed.
- Added experimental `linenoise.readLineStatus` to get line and status (e.g. ctrl-D or ctrl-C).
- Added `compilesettings.SingleValueSetting.libPath`.