Skip to content

Commit 2862665

Browse files
committed
Don't save implicit rest parameter into a local variable
1 parent 215c707 commit 2862665

File tree

5 files changed

+55
-123
lines changed

5 files changed

+55
-123
lines changed

spec/truffle/parsing/fixtures/block/argument_descriptors/with_implicit_rest_parameter.yaml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ subject: "Block"
22
description: "Argument descriptors / with implicit rest parameter (|a,|)"
33
notes: >
44
Implicit rest parameter should be ignored (there is no 'type=anonrest' descriptor).
5-
yarp_specific: true # there is no declaration of '*` local variable
5+
yarp_specific: true # there is no declaration of '*` local variable, don't save implicit rest parameter into local variable
66
focused_on_node: "org.truffleruby.language.methods.BlockDefinitionNode"
77
ruby: |
88
proc do |a,|
@@ -20,7 +20,7 @@ ast: |
2020
RubyProcRootNode
2121
attributes:
2222
callTarget = block in <top (required)>
23-
frameDescriptor = FrameDescriptor@...{#0:(self), #1:a, #2:%anonymous_rest, #3:%destructure_1}
23+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:a, #2:%destructure_1}
2424
instrumentationBits = 0
2525
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
2626
nextProfile = false
@@ -60,7 +60,7 @@ ast: |
6060
WriteLocalVariableNode
6161
attributes:
6262
flags = 0
63-
frameSlot = 3 # %destructure_1
63+
frameSlot = 2 # %destructure_1
6464
children:
6565
valueNode =
6666
SplatCastNodeGen
@@ -95,7 +95,7 @@ ast: |
9595
ReadLocalVariableNode
9696
attributes:
9797
flags = 0
98-
frameSlot = 3 # %destructure_1
98+
frameSlot = 2 # %destructure_1
9999
type = FRAME_LOCAL
100100
]
101101
elseBody =
@@ -135,19 +135,6 @@ ast: |
135135
index = 0
136136
keywordArguments = false
137137
missingArgumentBehavior = NIL
138-
WriteLocalVariableNode
139-
attributes:
140-
flags = 0
141-
frameSlot = 2 # %anonymous_rest
142-
children:
143-
valueNode =
144-
ReadRestArgumentNode
145-
attributes:
146-
flags = 0
147-
keywordArguments = false
148-
markKeywordHashWithFlag = false
149-
postArgumentsCount = 0
150-
startIndex = 1
151138
]
152139
thenBody =
153140
SequenceNode
@@ -184,25 +171,7 @@ ast: |
184171
ReadLocalVariableNode
185172
attributes:
186173
flags = 0
187-
frameSlot = 3 # %destructure_1
188-
type = FRAME_LOCAL
189-
WriteLocalVariableNode
190-
attributes:
191-
flags = 0
192-
frameSlot = 2 # %anonymous_rest
193-
children:
194-
valueNode =
195-
ArraySliceNodeGen
196-
attributes:
197-
flags = 0
198-
from = 1
199-
to = 0
200-
children:
201-
arrayNode_ =
202-
ReadLocalVariableNode
203-
attributes:
204-
flags = 0
205-
frameSlot = 3 # %destructure_1
174+
frameSlot = 2 # %destructure_1
206175
type = FRAME_LOCAL
207176
]
208177
NilLiteralNode

spec/truffle/parsing/fixtures/block/arity/with_implicit_rest_parameter.yaml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ subject: "Block"
22
description: "Arity / with implicit rest parameter (|a,|)"
33
notes: >
44
Implicit rest parameter should be ignored (see `hasRest=false`).
5-
yarp_specific: true # there is no declaration of '*` local variable
5+
yarp_specific: true # there is no declaration of '*` local variable, don't save implicit rest parameter into local variable
66
focused_on_node: "org.truffleruby.language.methods.BlockDefinitionNode"
77
ruby: |
88
proc do |a,|
@@ -20,7 +20,7 @@ ast: |
2020
RubyProcRootNode
2121
attributes:
2222
callTarget = block in <top (required)>
23-
frameDescriptor = FrameDescriptor@...{#0:(self), #1:a, #2:%anonymous_rest, #3:%destructure_1}
23+
frameDescriptor = FrameDescriptor@...{#0:(self), #1:a, #2:%destructure_1}
2424
instrumentationBits = 0
2525
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
2626
nextProfile = false
@@ -60,7 +60,7 @@ ast: |
6060
WriteLocalVariableNode
6161
attributes:
6262
flags = 0
63-
frameSlot = 3 # %destructure_1
63+
frameSlot = 2 # %destructure_1
6464
children:
6565
valueNode =
6666
SplatCastNodeGen
@@ -95,7 +95,7 @@ ast: |
9595
ReadLocalVariableNode
9696
attributes:
9797
flags = 0
98-
frameSlot = 3 # %destructure_1
98+
frameSlot = 2 # %destructure_1
9999
type = FRAME_LOCAL
100100
]
101101
elseBody =
@@ -135,19 +135,6 @@ ast: |
135135
index = 0
136136
keywordArguments = false
137137
missingArgumentBehavior = NIL
138-
WriteLocalVariableNode
139-
attributes:
140-
flags = 0
141-
frameSlot = 2 # %anonymous_rest
142-
children:
143-
valueNode =
144-
ReadRestArgumentNode
145-
attributes:
146-
flags = 0
147-
keywordArguments = false
148-
markKeywordHashWithFlag = false
149-
postArgumentsCount = 0
150-
startIndex = 1
151138
]
152139
thenBody =
153140
SequenceNode
@@ -184,25 +171,7 @@ ast: |
184171
ReadLocalVariableNode
185172
attributes:
186173
flags = 0
187-
frameSlot = 3 # %destructure_1
188-
type = FRAME_LOCAL
189-
WriteLocalVariableNode
190-
attributes:
191-
flags = 0
192-
frameSlot = 2 # %anonymous_rest
193-
children:
194-
valueNode =
195-
ArraySliceNodeGen
196-
attributes:
197-
flags = 0
198-
from = 1
199-
to = 0
200-
children:
201-
arrayNode_ =
202-
ReadLocalVariableNode
203-
attributes:
204-
flags = 0
205-
frameSlot = 3 # %destructure_1
174+
frameSlot = 2 # %destructure_1
206175
type = FRAME_LOCAL
207176
]
208177
NilLiteralNode

src/main/java/org/truffleruby/parser/TranslatorEnvironment.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public final class TranslatorEnvironment {
5353
public static final String METHOD_BLOCK_NAME = Layouts.TEMP_PREFIX + "method_block_arg";
5454
/** local variable name for * parameter */
5555
static final String DEFAULT_REST_NAME = ParserSupport.REST_VAR;
56-
/** local variable name for implicit rest parameter (e.g. |a, |) */
57-
static final String IMPLICIT_REST_NAME = Layouts.TEMP_PREFIX + "anonymous_rest";
5856
/** local variable name for ** parameter */
5957
static final String DEFAULT_KEYWORD_REST_NAME = ParserSupport.KWREST_VAR;
6058
/** local variable name for * parameter caused by desugaring ... parameter (forward-everything) */

0 commit comments

Comments
 (0)