Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix JRUBY-5632: [19] Incompatible behaviour of splat operator (*) wit…

…h objects that implement #to_a (w.r.t. MRI)
  • Loading branch information...
commit a0bd87b7075ddae1c2c727e907dfeb5ed6822731 1 parent d9cf1f1
Charles Oliver Nutter headius authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/org/jruby/javasupport/util/RuntimeHelpers.java
12 src/org/jruby/javasupport/util/RuntimeHelpers.java
View
@@ -1583,9 +1583,15 @@ public static RubyArray arrayValue(ThreadContext context, Ruby runtime, IRubyObj
// remove this hack too.
if (value.respondsTo("to_a") && value.getMetaClass().searchMethod("to_a").getImplementationClass() != runtime.getKernel()) {
- value = value.callMethod(context, "to_a");
- if (!(value instanceof RubyArray)) throw runtime.newTypeError("`to_a' did not return Array");
- return (RubyArray)value;
+ IRubyObject avalue = value.callMethod(context, "to_a");
+ if (!(avalue instanceof RubyArray)) {
+ if (runtime.is1_9() && avalue.isNil()) {
+ return runtime.newArray(value);
+ } else {
+ throw runtime.newTypeError("`to_a' did not return Array");
+ }
+ }
+ return (RubyArray)avalue;
} else {
return runtime.newArray(value);
}
Please sign in to comment.
Something went wrong with that request. Please try again.