D-Programming-Language/phobos — pull request #2235 by WebDrake (2014-06-08 17:05:33+00:00)
Title: Fix Issue #12877: allow uniform() to handle dchar variates

Since `[dchar.min, dchar.max]` does not cover the full bit range of `dchar`, optimizations that work for other integral types will fail here, and result in illegal unicode points being generated.

This fix avoids breaking any existing calls to `uniform()` via a twofold approach:

* `uniform!"[]"(T.min, T.max)` will only call `uniform!ResultType` if `T` is not a `dchar`;

* `uniform!dchar` will not try and use the entire bit range but will instead call `uniform!"[]"(dchar.min, dchar.max)`.

Unittests have been added that should prevent such issues from arising again.