From f4394bbca361c2bb500f586ba0bf1bef8b919910 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 27 Sep 2019 13:35:29 -0700 Subject: Do not autosplat when calling procs that accept rest and keywords When providing a single array to a block that takes a splat, pass the array as one argument of the splat instead of as the splat itself, even if the block also accepts keyword arguments. Previously, this behavior was only used for blocks that did not accept keywords. Implements [Feature#16166] --- vm_args.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vm_args.c') diff --git a/vm_args.c b/vm_args.c index e6d4981b33..50bb02311d 100644 --- a/vm_args.c +++ b/vm_args.c @@ -568,14 +568,14 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co rb_raise(rb_eArgError, "no keywords accepted"); } + switch (arg_setup_type) { case arg_setup_method: 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) && + (min_argc > 0 || iseq->body->param.opt_num > 1) && !iseq->body->param.flags.ambiguous_param0 && args_check_block_arg0(args)) { given_argc = RARRAY_LENINT(args->rest); -- cgit v1.2.3