diff options
author | Kevin Newton <kddnewton@gmail.com> | 2021-10-06 11:15:25 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:43 -0400 |
commit | c5acbd0208aa61e05718f73a093c7c6bdc142091 (patch) | |
tree | 877a3444ace9ed3497c86e1ab90b2c734b85636a /yjit_codegen.c | |
parent | 06a826b8c88e4d76d90bb5b9c3644387321b5fbc (diff) | |
download | ruby-c5acbd0208aa61e05718f73a093c7c6bdc142091.tar.gz |
Bail out if passing keyword arguments to only positional and/or optional methods
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index fa66ce4afb..8f49a358cf 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -3373,6 +3373,14 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r uint32_t start_pc_offset = 0; if (iseq_lead_only_arg_setup_p(iseq)) { + // If we have keyword arguments being passed to a callee that only takes + // positionals, then we need to allocate a hash. For now we're going to + // call that too complex and bail. + if (vm_ci_flag(ci) & VM_CALL_KWARG) { + GEN_COUNTER_INC(cb, send_iseq_complex_callee); + return YJIT_CANT_COMPILE; + } + num_params = iseq->body->param.lead_num; if (num_params != argc) { @@ -3381,6 +3389,14 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r } } else if (rb_iseq_only_optparam_p(iseq)) { + // If we have keyword arguments being passed to a callee that only takes + // positionals and optionals, then we need to allocate a hash. For now + // we're going to call that too complex and bail. + if (vm_ci_flag(ci) & VM_CALL_KWARG) { + GEN_COUNTER_INC(cb, send_iseq_complex_callee); + return YJIT_CANT_COMPILE; + } + // These are iseqs with 0 or more required parameters followed by 1 // or more optional parameters. // We follow the logic of vm_call_iseq_setup_normal_opt_start() |