Skip to content

Make upperBound != 0 a precondition for RNG.next(upperBound:) #17627

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

Merged

Conversation

stephentyrone
Copy link
Contributor

The function's definition is "Returns a random value that is less than the given upper bound," which cannot possibly be satisfied with upperBound == 0; previously the function returned zero, which was a bug.

Resolves SR-8143.

The function's definition is "Returns a random value that is less than the given upper bound," which cannot possibly be satisfied with upperBound == 0; previously the function returned zero, which was a bug.
@stephentyrone
Copy link
Contributor Author

@swift-ci Please smoke test.

@stephentyrone stephentyrone merged commit 6ebdefb into swiftlang:master Jun 29, 2018
@lorentey
Copy link
Member

👍 We should cherry-pick this into the 4.2 branch, too

stephentyrone added a commit to stephentyrone/swift that referenced this pull request Jun 29, 2018
…ang#17627)

The function's definition is "Returns a random value that is less than the given upper bound," which cannot possibly be satisfied with upperBound == 0; previously the function returned zero, which was a bug.
airspeedswift pushed a commit that referenced this pull request Jul 2, 2018
#17631)

The function's definition is "Returns a random value that is less than the given upper bound," which cannot possibly be satisfied with upperBound == 0; previously the function returned zero, which was a bug.
@stephentyrone stephentyrone deleted the random-upperbound-zero branch February 8, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants