Skip to content

Commit

Permalink
[Truffle] Check that blocks are instances of Proc.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Jul 13, 2016
1 parent 8e6192f commit dc8c8d4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -9,9 +9,11 @@
*/
package org.jruby.truffle.language.arguments;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.language.RubyNode;

public class ReadBlockNode extends RubyNode {
@@ -31,6 +33,11 @@ public Object execute(VirtualFrame frame) {
if (blockProfile.profile(block == null)) {
return valueIfAbsent;
} else {
if (!Layouts.PROC.isProc(block)) {
CompilerDirectives.transferToInterpreter();
throw new UnsupportedOperationException("Block isn't an instance of Proc");
}

return block;
}
}

0 comments on commit dc8c8d4

Please sign in to comment.