Skip to content

Commit

Permalink
Correctly set isModuleBody for parent frames for #eval
Browse files Browse the repository at this point in the history
* This fixes `eval "1.times { yield }"` to raise a SyntaxError like CRuby
  (and not a LocalJumpError like before).
  • Loading branch information
eregon committed Jun 21, 2022
1 parent e8a903b commit 3e4b726
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/truffleruby/parser/TranslatorDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,15 @@ private TranslatorEnvironment environmentForFrame(RubyContext context, Materiali
null);
final MaterializedFrame parent = RubyArguments.getDeclarationFrame(frame);
assert (blockDepth == 0) == (parent == null);
boolean isModuleBody = blockDepth == 0 &&
RubyArguments.getMethod(frame).getSharedMethodInfo().isModuleBody();

return new TranslatorEnvironment(
environmentForFrame(context, parent, blockDepth - 1),
parseEnvironment,
parseEnvironment.allocateReturnID(),
true,
false,
isModuleBody,
sharedMethodInfo,
sharedMethodInfo.getMethodName(),
blockDepth,
Expand Down

0 comments on commit 3e4b726

Please sign in to comment.