@@ -320,13 +320,17 @@ private Operand buildArray(ArrayNode node) {
320320 for (int i = 0 ; i < children .length ; i ++) {
321321 Node child = children [i ];
322322
323- if (child instanceof SplatNode ) {
323+ if (child instanceof SplatNode splat ) {
324324 int length = i - splatIndex - 1 ;
325325
326326 if (length == 0 ) {
327327 // FIXME: This is wasteful to force this all through argscat+empty array
328328 if (splatIndex == -1 ) copy (result , new Array ());
329- addResultInstr (new BuildCompoundArrayInstr (result , result , build (((SplatNode ) child ).expression ), false , false ));
329+ if (splat .expression instanceof NilNode ) {
330+ copy (result , new Array ());
331+ } else {
332+ addResultInstr (new BuildCompoundArrayInstr (result , result , build (splat .expression ), false , false ));
333+ }
330334 } else {
331335 Operand [] lhs = new Operand [length ];
332336 System .arraycopy (elts , splatIndex + 1 , lhs , 0 , length );
@@ -338,7 +342,7 @@ private Operand buildArray(ArrayNode node) {
338342 addResultInstr (new BuildCompoundArrayInstr (result , result , new Array (lhs ), false , false ));
339343 }
340344
341- addResultInstr (new BuildCompoundArrayInstr (result , result , build ((( SplatNode ) child ) .expression ), false , false ));
345+ addResultInstr (new BuildCompoundArrayInstr (result , result , build (splat .expression ), false , false ));
342346 }
343347 splatIndex = i ;
344348 } else if (child instanceof KeywordHashNode ) {
0 commit comments