File tree Expand file tree Collapse file tree 3 files changed +42
-2
lines changed
spec/truffle/parsing/fixtures/operators/multi_assignments
src/main/java/org/truffleruby/parser Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change
1
+ subject : " Multi-assignment"
2
+ description : " When implicit rest (a, = [])"
3
+ notes : >
4
+ Implicit rest is just ignored
5
+ focused_on_node : " org.truffleruby.core.array.MultipleAssignmentNode"
6
+ ruby : |
7
+ a, = []
8
+ ast : |
9
+ MultipleAssignmentNode
10
+ attributes:
11
+ flags = 1
12
+ children:
13
+ preNodes = [
14
+ WriteFrameSlotNodeGen
15
+ attributes:
16
+ frameSlot = 2 # a
17
+ ]
18
+ rhsNode =
19
+ ArrayLiteralNode$UninitialisedArrayLiteralNode
20
+ attributes:
21
+ flags = 0
22
+ language = org.truffleruby.RubyLanguage@...
23
+ splatCastNode =
24
+ SplatCastNodeGen
25
+ attributes:
26
+ conversionMethod = :to_ary
27
+ copy = true
28
+ flags = 0
29
+ nilBehavior = ARRAY_WITH_NIL
Original file line number Diff line number Diff line change @@ -262,7 +262,6 @@ public RubyNode visitImplicitRestNode(Nodes.ImplicitRestNode node) {
262
262
throw CompilerDirectives .shouldNotReachHere ("handled in #translateWithParameters" );
263
263
}
264
264
265
-
266
265
@ Override
267
266
public RubyNode visitKeywordRestParameterNode (Nodes .KeywordRestParameterNode node ) {
268
267
final RubyNode readNode = new ReadKeywordRestArgumentNode (language , arity );
Original file line number Diff line number Diff line change 9
9
*/
10
10
package org .truffleruby .parser ;
11
11
12
+ import com .oracle .truffle .api .CompilerDirectives ;
12
13
import org .prism .AbstractNodeVisitor ;
13
14
import org .prism .Nodes ;
14
15
import org .truffleruby .RubyLanguage ;
@@ -50,7 +51,13 @@ public RubyNode translate() {
50
51
51
52
final AssignableNode restNode ;
52
53
if (node .rest != null ) {
53
- restNode = node .rest .accept (this );
54
+ if (node .rest instanceof Nodes .ImplicitRestNode ) {
55
+ // a, = []
56
+ // do nothing
57
+ restNode = null ;
58
+ } else {
59
+ restNode = node .rest .accept (this );
60
+ }
54
61
} else {
55
62
restNode = null ;
56
63
}
@@ -99,6 +106,11 @@ public AssignableNode visitGlobalVariableTargetNode(Nodes.GlobalVariableTargetNo
99
106
return ((AssignableNode ) rubyNode ).toAssignableNode ();
100
107
}
101
108
109
+ @ Override
110
+ public AssignableNode visitImplicitRestNode (Nodes .ImplicitRestNode node ) {
111
+ throw CompilerDirectives .shouldNotReachHere ("handled in #translate" );
112
+ }
113
+
102
114
@ Override
103
115
public AssignableNode visitIndexTargetNode (Nodes .IndexTargetNode node ) {
104
116
final RubyNode rubyNode = node .accept (yarpTranslator );
You can’t perform that action at this time.
0 commit comments