-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
SecureRandom.random_number doesn't accept a range #4607
Comments
@Ruined1 it does indeed work but our securerandom.rb is identical in the sense that we both have a |
Oh haha...ok so it must be in C now and I must have missed it. That def random_number is in MRI source but it is commented out! with =begin. Why!?!?! :) |
Ok I was hoping to find something trivial to change here (since I am releasing 9.1.9.0 this morning) but I do not see where random_number is actually defined. There is no references to it in MRI C source and the only ruby definition is commented out. I half wonder if something like openssl gem defines it? |
@enebo I went through the same exact steps you did lol. Right away I was like "OH I got this! Then pull-request and good to go!", but no such luck lol. I hope this is solved soon, I cannot use JRuby without this... |
turns out its both - .rb parts are used but native ext is used. securerandom.rb is not up to date with MRI's |
@kares Thank you! |
The problem is here:
https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/securerandom.rb#L147
At some point, the code to handle ranges was removed.
Environment
jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [mswin32-x86_64]
Windows 10 Professional x64
Expected Behavior
In standard Ruby I can do
puts SecureRandom.random_number(50..55)
and get a random result between 50 and 55.Actual Behavior
If I do this in JRuby, I get an argument error for using a Range in place of a Fixnum.
The text was updated successfully, but these errors were encountered: