Skip to content

Commit fc9735a

Browse files
committed
The ArgumentsDescriptor for zsuper depends on whether the surrounding method accepts kwargs
* And on ruby2_keywords, but that's not handled yet anywhere.
1 parent b6b78dc commit fc9735a

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/main/java/org/truffleruby/language/supercall/SuperCallNode.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,7 @@ public final Object execute(VirtualFrame frame) {
5252
callSuperMethodNode = insert(CallSuperMethodNode.create());
5353
}
5454

55-
final ArgumentsDescriptor actualDescriptor;
56-
57-
if (descriptor == null) {
58-
actualDescriptor = RubyArguments.getDescriptor(frame);
59-
} else {
60-
actualDescriptor = descriptor;
61-
}
62-
63-
return callSuperMethodNode.execute(frame, self, superMethod, actualDescriptor, superArguments, blockObject);
55+
return callSuperMethodNode.execute(frame, self, superMethod, descriptor, superArguments, blockObject);
6456
}
6557

6658
@Override

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.truffleruby.language.RubyNode;
2626
import org.truffleruby.language.RubyProcRootNode;
2727
import org.truffleruby.language.SourceIndexLength;
28+
import org.truffleruby.language.arguments.ArgumentsDescriptor;
29+
import org.truffleruby.language.arguments.EmptyArgumentsDescriptor;
30+
import org.truffleruby.language.arguments.KeywordArgumentsDescriptor;
2831
import org.truffleruby.language.arguments.MissingArgumentBehavior;
2932
import org.truffleruby.language.arguments.ReadPreArgumentNode;
3033
import org.truffleruby.language.arguments.ShouldDestructureNode;
@@ -485,12 +488,15 @@ public RubyNode visitZSuperNode(ZSuperParseNode node) {
485488
final ArgsParseNode argsNode = methodArgumentsTranslator.argsNode;
486489
final SequenceNode reloadSequence = (SequenceNode) reloadTranslator.visitArgsNode(argsNode);
487490

491+
final ArgumentsDescriptor descriptor = argsNode.hasKwargs()
492+
? KeywordArgumentsDescriptor.INSTANCE
493+
: EmptyArgumentsDescriptor.INSTANCE;
488494
final RubyNode arguments = new ReadZSuperArgumentsNode(
489495
reloadTranslator.getRestParameterIndex(),
490496
reloadSequence.getSequence());
491497
final RubyNode block = executeOrInheritBlock(argumentsAndBlock.getBlock(), node);
492498

493-
RubyNode callNode = new SuperCallNode(arguments, block, null);
499+
RubyNode callNode = new SuperCallNode(arguments, block, descriptor);
494500
callNode = wrapCallWithLiteralBlock(argumentsAndBlock, callNode);
495501

496502
return withSourceSection(sourceSection, callNode);

0 commit comments

Comments
 (0)