Skip to content

Commit

Permalink
Fixing RangeError with code from 1.7 branch
Browse files Browse the repository at this point in the history
With my previous commit, RangeError: bignum too big to convert into `long' was the result when running (0...2**64).max

This commit ports handling for non-RubyFixnums from the 1.7.20 branch.

Addresses, jruby#3118
  • Loading branch information
bigsur0 committed Jul 31, 2015
1 parent d79f665 commit d840ad5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/RubyRange.java
Expand Up @@ -659,7 +659,11 @@ public IRubyObject max(ThreadContext context, Block block) {
if (!(begin instanceof RubyInteger)) {
throw context.runtime.newTypeError("cannot exclude end value with non Integer begin value");
}
rangeEnd = RubyFixnum.newFixnum(context.runtime, ((RubyInteger) end).getLongValue() - 1);
if (end instanceof RubyFixnum) {
rangeEnd = RubyFixnum.newFixnum(context.runtime, ((RubyFixnum)end).getLongValue() - 1);
else {
rangeEnd = end.callMethod(context, "-", RubyFixnum.one(context.runtime));
}
} else {
rangeEnd = end;
}
Expand Down

0 comments on commit d840ad5

Please sign in to comment.