Skip to content

Commit 66b85c2

Browse files
authored
Merge pull request jruby#9247 from evaniainbrooks/array-slice-tags
Fix Array#slice raises a RangeError when the start index is out of range of Fixnum
2 parents 6ed4909 + 9a02420 commit 66b85c2

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

core/src/main/java/org/jruby/RubyNumeric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private static long other2long(IRubyObject arg) throws RaiseException {
297297
@Deprecated(since = "10.0.0.0")
298298
public static long float2long(RubyFloat flt) {
299299
final double aFloat = flt.value;
300-
if (aFloat <= (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) {
300+
if (aFloat < (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) {
301301
return (long) aFloat;
302302
}
303303
// TODO: number formatting here, MRI uses "%-.10g", 1.4 API is a must?

core/src/main/java/org/jruby/api/Convert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public static long toLong(ThreadContext context, RubyBignum value) {
532532
public static long toLong(ThreadContext context, RubyFloat value) {
533533
final double aFloat = value.getValue();
534534

535-
if (aFloat <= (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) {
535+
if (aFloat < (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) {
536536
return (long) aFloat;
537537
}
538538

@@ -566,7 +566,7 @@ public static int toInt(ThreadContext context, IRubyObject arg) {
566566
public static long toInt(ThreadContext context, RubyFloat value) {
567567
final double aFloat = value.getValue();
568568

569-
if (aFloat <= (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) {
569+
if (aFloat < (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) {
570570
return (long) aFloat;
571571
}
572572

spec/tags/ruby/core/array/slice_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)