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

[SR-8143] Should RNG.next(upperBound: 0) be a preconditionFailure? #50675

Closed
stephentyrone opened this issue Jun 28, 2018 · 6 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@stephentyrone
Copy link
Member

Previous ID SR-8143
Radar rdar://problem/41735302
Original Reporter @stephentyrone
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee @stephentyrone
Priority Medium

md5: aa7632d8600c5ad6ba8cbd93aa8f3d7c

Issue Description:

Presently we have the following:

guard upperBound != 0 else { return 0 }

This seems like a pretty glaring violation of the documented behavior: "Returns a random value that is less than the given upper bound."

@stephentyrone
Copy link
Member Author

It's entirely possible that I simply missed the discussion where this was decided. CC @natecook1000 @airspeedswift

@lorentey
Copy link
Member

I agree, we should clearly trap here.

@stephentyrone
Copy link
Member Author

I'll fix this on master and we should consider pulling it into 4.2.

@stephentyrone
Copy link
Member Author

#17627

@stephentyrone
Copy link
Member Author

and #17631 for 4.2

@airspeedswift
Copy link
Member

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants