Skip to content

Commit 7cccb7e

Browse files
committed
Ignore empty kwrest in Data subtypes' constructors
When passing empty kwrest into a method, `hasKeyword` will be true but there will not actually be any keyword hash in the argument list. We need to also check for "empty" keywords before proceeding to use any incoming kwargs hash. Fixes jruby#9214
1 parent f21870a commit 7cccb7e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

core/src/main/java/org/jruby/RubyData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import static org.jruby.runtime.Arity.checkArgumentCount;
4141
import static org.jruby.runtime.Helpers.invokedynamic;
4242
import static org.jruby.runtime.ThreadContext.CALL_KEYWORD;
43+
import static org.jruby.runtime.ThreadContext.CALL_KEYWORD_EMPTY;
4344
import static org.jruby.runtime.ThreadContext.clearCallInfo;
4445
import static org.jruby.runtime.ThreadContext.hasKeywords;
4546
import static org.jruby.runtime.ThreadContext.resetCallInfo;
@@ -309,7 +310,7 @@ public static IRubyObject rbNew(ThreadContext context, IRubyObject self, IRubyOb
309310

310311
RubyHash init;
311312
int callInfo = resetCallInfo(context);
312-
if (hasKeywords(callInfo)) {
313+
if (hasKeywords(callInfo) && (callInfo & CALL_KEYWORD_EMPTY) == 0) {
313314
if (!(hashOrElt instanceof RubyHash)) {
314315
throw argumentError(context, 1, 0, 0);
315316
}

0 commit comments

Comments
 (0)