Skip to content

Commit

Permalink
[Truffle] Raise the correct exception type if type cannot be coerced …
Browse files Browse the repository at this point in the history
…into String.
  • Loading branch information
nirvdrum committed Dec 5, 2014
1 parent 3c98a0f commit 87f93a1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,20 @@ public Object eval(RubyString source, RubyBinding binding) {
public Object eval(VirtualFrame frame, RubyBasicObject object, UndefinedPlaceholder binding) {
notDesignedForCompilation();

RubyString coerced = (RubyString) toStr.call(frame, object, "to_str", null);

return getContext().eval(coerced.toString(), this);
try {
RubyString coerced = (RubyString) toStr.call(frame, object, "to_str", null);

return getContext().eval(coerced.toString(), this);
} catch (RaiseException e) {
if (e.getRubyException().getLogicalClass() == getContext().getCoreLibrary().getNoMethodErrorClass()) {
throw new RaiseException(
getContext().getCoreLibrary().typeError(
String.format("no implicit conversion of %s into String", object.getLogicalClass().getName()),
this));
} else {
throw e;
}
}
}
}

Expand Down

0 comments on commit 87f93a1

Please sign in to comment.