Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Add necessary handling of Dispath.MISSING when we use RETUR…
…N_MISSING behavior.
  • Loading branch information
eregon committed Dec 29, 2014
1 parent 6199915 commit 13e2779
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -103,13 +103,14 @@ public RubyArray splat(VirtualFrame frame, Object object) {
method = "to_a";
}

// TODO(CS): why are we directly calling #respond_to? instead of using a respondsTo on a dispatch head node?
if (respondToCast.executeBoolean(frame, respondToToA.call(frame, object, "respond_to?", null, getContext().makeString(method), true))) {
// MRI tries to call dynamic respond_to? here.
Object respondToResult = respondToToA.call(frame, object, "respond_to?", null, getContext().makeString(method), true);
if (respondToResult != Dispatch.MISSING && respondToCast.executeBoolean(frame, respondToResult)) {
final Object array = toA.call(frame, object, method, null);

if (array instanceof RubyArray) {
return (RubyArray) array;
} else if (array instanceof RubyNilClass) {
} else if (array instanceof RubyNilClass || array == Dispatch.MISSING) {
return RubyArray.fromObject(getContext().getCoreLibrary().getArrayClass(), object);
} else {
throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertTo(
Expand Down

0 comments on commit 13e2779

Please sign in to comment.