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
  • Loading branch information
headius committed Dec 14, 2016
1 parent 48f1ac2 commit a91b6f4
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 169 deletions.
12 changes: 5 additions & 7 deletions core/src/main/java/org/jruby/RubyNumeric.java
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyRational.java
Expand Up @@ -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
Expand Down

0 comments on commit a91b6f4

Please sign in to comment.