Skip to content

Commit

Permalink
First stages of re-porting BigDecimal logic from MRI.
Browse files Browse the repository at this point in the history
headius committed Dec 14, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 48f1ac2 commit a91b6f4
Showing 3 changed files with 188 additions and 169 deletions.
12 changes: 5 additions & 7 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -421,8 +421,7 @@ protected final IRubyObject[] getCoerced(ThreadContext context, IRubyObject othe
final IRubyObject result;
try {
result = sites(context).coerce.call(context, other, other, this);
}
catch (RaiseException e) { // e.g. NoMethodError: undefined method `coerce'
} catch (RaiseException e) { // e.g. NoMethodError: undefined method `coerce'
context.setErrorInfo($ex); // restore $!

if (error) {
@@ -492,16 +491,15 @@ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boo
final IRubyObject result;
try {
result = coerceBody(context, other);
}
catch (RaiseException e) { // e.g. NoMethodError: undefined method `coerce'
} catch (RaiseException e) { // e.g. NoMethodError: undefined method `coerce'
if (context.runtime.getStandardError().isInstance( e.getException() )) {
context.setErrorInfo($ex); // restore $!
RubyWarnings warnings = context.runtime.getWarnings();
warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
if (err) {
coerceFailed(context, other);
}
RubyWarnings warnings = context.runtime.getWarnings();
warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
return null;
}
throw e;
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyRational.java
Original file line number Diff line number Diff line change
@@ -706,7 +706,7 @@ public IRubyObject op_coerce(ThreadContext context, IRubyObject other) {
} else if (other instanceof RubyRational) {
return runtime.newArray(other, this);
}
throw runtime.newTypeError(other.getMetaClass() + " can't be coerced into " + getMetaClass());
return context.nil;
}

/** nurat_idiv
Loading

0 comments on commit a91b6f4

Please sign in to comment.