File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
src/main/java/org/truffleruby Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ public abstract class HashSubtractKeysNode extends RubyContextSourceNode impleme
29
29
@ Child private HashStoreLibrary hashes = HashStoreLibrary .createDispatched ();
30
30
31
31
public HashSubtractKeysNode (RubySymbol [] excludedKeys ) {
32
+ assert excludedKeys .length > 0 : "unnecessary" ;
32
33
this .excludedKeys = excludedKeys ;
33
34
}
34
35
Original file line number Diff line number Diff line change @@ -249,10 +249,13 @@ public RubyNode visitHashPatternNode(Nodes.HashPatternNode node) {
249
249
250
250
var rest = node .rest ;
251
251
if (rest != null ) {
252
+ RubyNode withoutMatchedKeys = keys .length == 0
253
+ ? readTemp
254
+ : HashSubtractKeysNodeGen .create (keys , readTemp );
252
255
if (rest instanceof Nodes .AssocSplatNode assocSplatNode ) {
253
256
if (assocSplatNode .value != null ) {
254
257
RubyNode prev = currentValueToMatch ;
255
- currentValueToMatch = HashSubtractKeysNodeGen . create ( keys , readTemp ) ;
258
+ currentValueToMatch = withoutMatchedKeys ;
256
259
try {
257
260
condition = AndNodeGen .create (condition , assocSplatNode .value .accept (this ));
258
261
} finally {
@@ -262,8 +265,7 @@ public RubyNode visitHashPatternNode(Nodes.HashPatternNode node) {
262
265
// nothing
263
266
}
264
267
} else if (rest instanceof Nodes .NoKeywordsParameterNode ) {
265
- condition = AndNodeGen .create (condition ,
266
- new HashIsEmptyNode (HashSubtractKeysNodeGen .create (keys , readTemp )));
268
+ condition = AndNodeGen .create (condition , new HashIsEmptyNode (withoutMatchedKeys ));
267
269
} else {
268
270
throw fail (rest );
269
271
}
You can’t perform that action at this time.
0 commit comments