Skip to content

Commit 03bba72

Browse files
committed
*nil should not to_ary
1 parent 592a249 commit 03bba72

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/org/jruby/prism/builder/IRBuilderPrism.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)