@@ -188,6 +188,10 @@ public class YARPTranslator extends AbstractNodeVisitor<RubyNode> {
188
188
189
189
public static final int NO_FRAME_ON_STACK_MARKER = Translator .NO_FRAME_ON_STACK_MARKER ;
190
190
191
+ public static final Nodes .Node [] EMPTY_NODE_ARRAY = Nodes .Node .EMPTY_ARRAY ;
192
+ public static final Nodes .ParametersNode ZERO_PARAMETERS_NODE = new Nodes .ParametersNode (EMPTY_NODE_ARRAY ,
193
+ EMPTY_NODE_ARRAY , null , EMPTY_NODE_ARRAY , EMPTY_NODE_ARRAY , null , null , 0 , 0 );
194
+
191
195
public static final RescueNode [] EMPTY_RESCUE_NODE_ARRAY = new RescueNode [0 ];
192
196
193
197
protected static final short NO_FLAGS = 0 ;
@@ -415,7 +419,7 @@ public RubyNode visitBeginNode(Nodes.BeginNode node) {
415
419
416
420
private RescueNode translateExceptionNodes (ArrayList <Nodes .Node > exceptionNodes , Nodes .RescueNode rescueClause ) {
417
421
418
- final Nodes .Node [] exceptionNodesArray = exceptionNodes .toArray (Nodes . Node . EMPTY_ARRAY );
422
+ final Nodes .Node [] exceptionNodesArray = exceptionNodes .toArray (EMPTY_NODE_ARRAY );
419
423
final RubyNode [] handlingClasses = translate (exceptionNodesArray );
420
424
421
425
RubyNode translatedBody ;
@@ -482,8 +486,8 @@ private RubyNode translateBlockAndLambda(Nodes.Node node, Nodes.BlockParametersN
482
486
for (int i = 1 ; i <= max ; i ++) {
483
487
requireds [i - 1 ] = new Nodes .RequiredParameterNode ("_" + i , 0 , 0 );
484
488
}
485
- parameters = new Nodes .ParametersNode (requireds , Nodes . Node . EMPTY_ARRAY , null , Nodes . Node . EMPTY_ARRAY ,
486
- Nodes . Node . EMPTY_ARRAY , null , null , 0 , 0 );
489
+ parameters = new Nodes .ParametersNode (requireds , EMPTY_NODE_ARRAY , null , EMPTY_NODE_ARRAY ,
490
+ EMPTY_NODE_ARRAY , null , null , 0 , 0 );
487
491
} else {
488
492
// no numbered parameters
489
493
parameters = null ;
@@ -656,7 +660,7 @@ private ArgumentsAndBlockTranslation translateArgumentsAndBlock(Nodes.ArgumentsN
656
660
String methodName ) {
657
661
final Nodes .Node [] arguments ;
658
662
if (argumentsNode == null ) {
659
- arguments = Nodes . Node . EMPTY_ARRAY ;
663
+ arguments = EMPTY_NODE_ARRAY ;
660
664
} else {
661
665
arguments = argumentsNode .arguments ;
662
666
}
@@ -1282,6 +1286,10 @@ public RubyNode visitForwardingSuperNode(Nodes.ForwardingSuperNode node) {
1282
1286
1283
1287
// TODO: could we use the ArgumentDescriptor[] stored in the SharedMethodInfo instead?
1284
1288
var parametersNode = environment .parametersNode ;
1289
+ if (parametersNode == null ) {
1290
+ // parametersNode == null for a method means zero parameters: https://github.com/ruby/prism/issues/1915
1291
+ parametersNode = ZERO_PARAMETERS_NODE ;
1292
+ }
1285
1293
var reloadTranslator = new YARPReloadArgumentsTranslator (language , this , parametersNode );
1286
1294
1287
1295
final RubyNode [] reloadSequence = reloadTranslator .reload (parametersNode );
0 commit comments