Skip to content

Commit d9092b1

Browse files
committed
Fix Kernel#lambda to get block from method if block not given.
1 parent 775961b commit d9092b1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/org/truffleruby/core/kernel/KernelNodes.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,11 +999,12 @@ public abstract static class LambdaNode extends CoreMethodArrayArgumentsNode {
999999

10001000
@TruffleBoundary
10011001
@Specialization
1002-
public DynamicObject lambda(NotProvided block) {
1003-
final Frame parentFrame = getContext().getCallStack().getCallerFrameIgnoringSend(0).getFrame(FrameAccess.READ_ONLY);
1004-
final DynamicObject parentBlock = RubyArguments.getBlock(parentFrame);
1002+
public DynamicObject lambda(NotProvided block,
1003+
@Cached("create(nil())") FindAndReadDeclarationVariableNode readNode) {
1004+
final MaterializedFrame parentFrame = getContext().getCallStack().getCallerFrameIgnoringSend(0).getFrame(FrameAccess.MATERIALIZE).materialize();
1005+
DynamicObject parentBlock = (DynamicObject) readNode.execute(parentFrame, TranslatorEnvironment.METHOD_BLOCK_NAME);
10051006

1006-
if (parentBlock == null) {
1007+
if (parentBlock == nil()) {
10071008
throw new RaiseException(getContext(), coreExceptions().argumentError("tried to create Proc object without a block", this));
10081009
} else {
10091010
warnProcWithoutBlock();

0 commit comments

Comments
 (0)