|
27 | 27 | import org.truffleruby.language.SourceIndexLength;
|
28 | 28 | import org.truffleruby.language.arguments.MissingArgumentBehavior;
|
29 | 29 | import org.truffleruby.language.arguments.ProfileArgumentNodeGen;
|
30 |
| -import org.truffleruby.language.arguments.ReadBlockNode; |
31 | 30 | import org.truffleruby.language.arguments.ReadPreArgumentNode;
|
32 | 31 | import org.truffleruby.language.arguments.ShouldDestructureNode;
|
33 | 32 | import org.truffleruby.language.control.AndNode;
|
@@ -319,7 +318,7 @@ public RubyNode visitSuperNode(SuperParseNode node) {
|
319 | 318 | final ArgumentsAndBlockTranslation argumentsAndBlock = translateArgumentsAndBlock(sourceSection, node.getIterNode(), node.getArgsNode(), environment.getNamedMethodName());
|
320 | 319 |
|
321 | 320 | final RubyNode arguments = new ReadSuperArgumentsNode(argumentsAndBlock.getArguments(), argumentsAndBlock.isSplatted());
|
322 |
| - final RubyNode block = executeOrInheritBlock(argumentsAndBlock.getBlock()); |
| 321 | + final RubyNode block = executeOrInheritBlock(argumentsAndBlock.getBlock(), node); |
323 | 322 |
|
324 | 323 | RubyNode callNode = new SuperCallNode(arguments, block);
|
325 | 324 | callNode = wrapCallWithLiteralBlock(argumentsAndBlock, callNode);
|
@@ -354,19 +353,19 @@ public RubyNode visitZSuperNode(ZSuperParseNode node) {
|
354 | 353 | final RubyNode arguments = new ReadZSuperArgumentsNode(
|
355 | 354 | reloadTranslator.getRestParameterIndex(),
|
356 | 355 | reloadSequence.getSequence());
|
357 |
| - final RubyNode block = executeOrInheritBlock(argumentsAndBlock.getBlock()); |
| 356 | + final RubyNode block = executeOrInheritBlock(argumentsAndBlock.getBlock(), node); |
358 | 357 |
|
359 | 358 | RubyNode callNode = new SuperCallNode(arguments, block);
|
360 | 359 | callNode = wrapCallWithLiteralBlock(argumentsAndBlock, callNode);
|
361 | 360 |
|
362 | 361 | return withSourceSection(sourceSection, callNode);
|
363 | 362 | }
|
364 | 363 |
|
365 |
| - private RubyNode executeOrInheritBlock(RubyNode blockNode) { |
| 364 | + private RubyNode executeOrInheritBlock(RubyNode blockNode, ParseNode callNode) { |
366 | 365 | if (blockNode != null) {
|
367 | 366 | return blockNode;
|
368 | 367 | } else {
|
369 |
| - return new ReadBlockNode(context.getCoreLibrary().getNil()); |
| 368 | + return environment.findLocalVarOrNilNode(TranslatorEnvironment.METHOD_BLOCK_NAME, callNode.getPosition()); |
370 | 369 | }
|
371 | 370 | }
|
372 | 371 |
|
|
0 commit comments