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

thread 'main' panicked at 'cannot sample empty range' #41

Open
bbrk24 opened this issue Apr 1, 2022 · 2 comments · May be fixed by #42
Open

thread 'main' panicked at 'cannot sample empty range' #41

bbrk24 opened this issue Apr 1, 2022 · 2 comments · May be fixed by #42

Comments

@bbrk24
Copy link

bbrk24 commented Apr 1, 2022

Apparently ChuckSomeDice really doesn't like non-integers, as this code:

G'DAY MATE!
IMPOHT ME FUNC ChuckSomeDice;
ChuckSomeDice(0, 0.5);
CHEERS C***!

outputs the following error:

thread 'main' panicked at 'cannot sample empty range', /Users/zackradisic/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.8.4/src/rng.rs:134:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@bbrk24
Copy link
Author

bbrk24 commented Apr 1, 2022

Actually, I think I can get a PR out for this.

@bbrk24 bbrk24 linked a pull request Apr 2, 2022 that will close this issue
@dspingarn
Copy link

dspingarn commented May 17, 2022

I know there's a PR for this, but just want to add that ChuckSomeDice is basically a fancy alias for rand() which only takes integers anyway (specifically, the datatype is an i64) so you'd expect 0.5 to truncate to just 0, per integer truncating.
The bug, of course, is that ChuckSomeDice(0,0) should display the proper error message, which is what ^this PR will fix, and you do reference this in the PR itself.

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 a pull request may close this issue.

2 participants