Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 20cada438ad7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1a98cd304ebe
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 26, 2018

  1. Numeric#clone and #dup no longer raises TypeError

    It returns the receiver instead as well as Integer and Float.
    
    For more information, please see bug #13237.
    nomadium committed Mar 26, 2018
    Copy the full SHA
    820f7e6 View commit details
  2. Merge pull request #5113 from nomadium/ruby-2.5-numeric-clone

    Numeric#clone and #dup no longer raises TypeError
    headius authored Mar 26, 2018
    Copy the full SHA
    1a98cd3 View commit details
Showing with 22 additions and 1 deletion.
  1. +1 −1 core/src/main/java/org/jruby/RubyBasicObject.java
  2. +21 −0 core/src/main/java/org/jruby/RubyNumeric.java
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -511,7 +511,7 @@ public boolean isSpecialConst() {

// MRI: special_object_p
public boolean isSpecialObject() {
return isImmediate() || this instanceof RubyBignum || this instanceof RubyFloat;
return isImmediate() || this instanceof RubyBignum || this instanceof RubyFloat || this instanceof RubyRational || this instanceof RubyComplex;
}

/**
21 changes: 21 additions & 0 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -1403,6 +1403,27 @@ public IRubyObject infinite_p(ThreadContext context) {
return context.runtime.getNil();
}

@JRubyMethod(name = "clone", required = 0, optional = 1)
public IRubyObject rbClone(IRubyObject[] args) {
if (args.length == 0) return this;

Ruby runtime = args[0].getRuntime();

if (!(args[0] instanceof RubyHash)) {
throw runtime.newArgumentError("wrong number of arguments (given " + args.length + ", expected 0)");
}

IRubyObject[] rets = ArgsUtil.extractKeywordArgs(runtime.getCurrentContext(), args[0].convertToHash(), "freeze");
if (!rets[0].isTrue()) throw runtime.newArgumentError("can't unfreeze " + getType());

return this;
}

@Override
public IRubyObject dup() {
return this;
}

public static IRubyObject numFuncall(ThreadContext context, IRubyObject x, CallSite site) {
return context.safeRecurse(new NumFuncall0(), site, x, site.methodName, true);
}