Skip to content

Commit

Permalink
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/language/variables_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
fails:Multiple assignment with a single RHS value assigns a single LHS splat
fails:Multiple assignment with a single RHS value assigns an Array when the RHS is an Array subclass
fails:Multiple assignment with a single RHS value calls #to_ary to convert an Object RHS
fails:Multiple assignment with a single RHS value calls #to_ary to convert an Object RHS with MLHS
fails:Multiple assignment with a single RHS value does not mutate a RHS Array
fails:Multiple assignment with a single RHS value raises a TypeError if #to_ary does not return an Array
fails:Multiple assignment with a single splatted RHS value assigns a MLHS with leading splat
fails:Multiple assignment with a single splatted RHS value calls #to_a to convert an Object RHS with MLHS
fails:Multiple assignment with a single splatted RHS value calls #to_a to convert nil to an empty Array
fails:Multiple assignment with a single splatted RHS value does not mutate a RHS Array
Original file line number Diff line number Diff line change
@@ -2115,11 +2115,20 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {
*
* a = *b
*/

final List<RubyNode> sequence = new ArrayList<>();

final String tempRHSName = environment.allocateLocalTemp("rhs");
final RubyNode writeTempRHS = environment.findLocalVarNode(tempRHSName, sourceSection).makeWriteNode(rhsTranslated);
sequence.add(writeTempRHS);

final SplatCastNode rhsSplatCast = SplatCastNodeGen.create(context, sourceSection,
translatingNextExpression ? SplatCastNode.NilBehavior.EMPTY_ARRAY : SplatCastNode.NilBehavior.ARRAY_WITH_NIL,
false, rhsTranslated);
false, environment.findLocalVarNode(tempRHSName, sourceSection));

result = translateDummyAssignment(node.getRest(), rhsSplatCast);
sequence.add(translateDummyAssignment(node.getRest(), rhsSplatCast));

result = new ElidableResultNode(context, sourceSection, SequenceNode.sequence(context, sourceSection, sequence), environment.findLocalVarNode(tempRHSName, sourceSection));
} else if (node.getPre() == null
&& node.getPost() == null
&& node.getRest() != null

0 comments on commit 5a3ac6d

Please sign in to comment.