Skip to content
Browse files

Fix JRUBY-5950: When to_ary from yield does not return an array we Cl…

…assCast
  • Loading branch information...
1 parent 22ba5c4 commit d8453fb69b1d83affecefb1ad9337efb60717cfc @headius headius committed Aug 16, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/org/jruby/ast/util/ArgsUtil.java
View
7 src/org/jruby/ast/util/ArgsUtil.java
@@ -81,8 +81,11 @@ public static RubyArray convertToRubyArrayWithCoerce(Ruby runtime, IRubyObject v
return RubyArray.newArrayLight(runtime, value);
}
- // empirically it appears that to_ary coersions always return array or nil, so this
- // should always be an array by now.
+ // must be array by now, or error
+ if (!(newValue instanceof RubyArray)) {
+ throw runtime.newTypeError(newValue.getMetaClass() + "#" + "to_ary" + " should return Array");
+ }
+
return (RubyArray)newValue;
}

0 comments on commit d8453fb

Please sign in to comment.
Something went wrong with that request. Please try again.