Skip to content
Permalink
Browse files
[Truffle] Raise the correct exception type if type cannot be coerced …
…into String.
  • Loading branch information
nirvdrum committed Dec 5, 2014
1 parent 3c98a0f commit 87f93a1b636e8d1d10981b13d3e5f9f1e5c4f6cb
Showing with 14 additions and 3 deletions.
  1. +14 −3 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
@@ -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;
}
}
}
}

0 comments on commit 87f93a1

Please sign in to comment.