Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #12877: allow uniform() to handle dchar variates #2235

Merged
merged 1 commit into from Jun 10, 2014

Conversation

WebDrake
Copy link
Contributor

@WebDrake WebDrake commented Jun 8, 2014

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.

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.
monarchdodra added a commit that referenced this pull request Jun 10, 2014
Fix Issue #12877: allow uniform() to handle dchar variates
@monarchdodra monarchdodra merged commit 240a11e into dlang:master Jun 10, 2014
@WebDrake
Copy link
Contributor Author

Awesome, thanks! :-)

@WebDrake WebDrake deleted the uniform-dchar branch June 10, 2014 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants