Skip to content

Commit

Permalink
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -561,6 +561,10 @@ protected Variable copyAndReturnValue(Operand val) {
}

protected Operand buildWithOrder(Node node, boolean preserveOrder) {
// Even though String literals are mutable they cannot fail or depend on rest of program's semantics so
// they can ignore order.
if (node instanceof StrNode) return buildStrRaw((StrNode) node);

Operand value = build(node);

// We need to preserve order in cases (like in presence of assignments) except that immutable
@@ -828,7 +832,7 @@ public Operand buildArray(ArrayNode node, boolean operandOnly) {
Operand[] elts = new Operand[nodes.length];
boolean containsAssignments = node.containsVariableAssignment();
for (int i = 0; i < nodes.length; i++) {
elts[i] = nodes[i] instanceof StrNode ? buildStrRaw((StrNode) nodes[i]) : buildWithOrder(nodes[i], containsAssignments);
elts[i] = buildWithOrder(nodes[i], containsAssignments);
}

Operand array = new Array(elts);

0 comments on commit a1047ee

Please sign in to comment.