From 4aea2b7db6d14d4030beaba463d27cb49c7d5e21 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Wed, 8 May 2024 12:57:32 -0500 Subject: [PATCH] Only do this optimization for method scopes Non-method scopes like classes and modules have issues with the frame name not properly propagating into the executing body, and blocks may be used for define_method which introduces similar complexities in getting the frame name. This patch temporarily narrows the frame name optimization to method bodies only. --- core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java b/core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java index eb903e2975d..9f7f1782314 100644 --- a/core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java +++ b/core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java @@ -2655,8 +2655,11 @@ public Operand buildVCall(Variable result, VCallNode node) { switch (callName) { case "__method__": case "__callee__": - addInstr(new FrameNameCallInstr(result, callName)); - return result; + // narrow to methods until we can fix other scopes' frame names + if (scope instanceof IRMethod) { + addInstr(new FrameNameCallInstr(result, callName)); + return result; + } } return _call(result, VARIABLE, buildSelf(), node.getName());