aboutsummaryrefslogtreecommitdiffstats
path: root/vm_args.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-01-24 12:13:41 -0800
committerJeremy Evans <code@jeremyevans.net>2020-01-24 13:04:14 -0800
commitc1d8829ef515ee51fadeadd7dd022b5c47a71cdd (patch)
tree19855350cd3319a95221c4726036e47d9fae3acc /vm_args.c
parent9af7d048b6e2f5221dfb7bb757fd6cb5d5757124 (diff)
downloadruby-c1d8829ef515ee51fadeadd7dd022b5c47a71cdd.tar.gz
Do not autosplat when calling proc with empty keyword splat
With the removal of the splatted argument when using an empty keyword splat, the autosplat code considered an empty keyword splat the same as no argument at all. However, that results in autosplat behavior changing dependent on the content of the splatted hash, which is not what anyone would expect or want. This change always skips an autosplat if keywords were provided. Fixes [Bug #16560]
Diffstat (limited to 'vm_args.c')
-rw-r--r--vm_args.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/vm_args.c b/vm_args.c
index 256ab5b7f4..13d4e4a545 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -445,9 +445,9 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
{
const int min_argc = iseq->body->param.lead_num + iseq->body->param.post_num;
const int max_argc = (iseq->body->param.flags.has_rest == FALSE) ? min_argc + iseq->body->param.opt_num : UNLIMITED_ARGUMENTS;
- int opt_pc = 0;
int given_argc;
unsigned int kw_flag = ci->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT);
+ int opt_pc = 0, allow_autosplat = !kw_flag;
struct args_info args_body, *args;
VALUE keyword_hash = Qnil;
VALUE * const orig_sp = ec->cfp->sp;
@@ -573,6 +573,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
break; /* do nothing special */
case arg_setup_block:
if (given_argc == (keyword_hash == Qnil ? 1 : 2) &&
+ allow_autosplat &&
(min_argc > 0 || iseq->body->param.opt_num > 1 ||
iseq->body->param.flags.has_kw || iseq->body->param.flags.has_kwrest) &&
!iseq->body->param.flags.ambiguous_param0 &&