diff options
author | Jeremy Evans <[email protected]> | 2019-09-27 13:35:29 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2020-03-08 20:49:09 -0700 |
commit | f4394bbca361c2bb500f586ba0bf1bef8b919910 (patch) | |
tree | fea4e00e12d0dcbf6a76d7d4b7e95e6db34583c1 /vm_args.c | |
parent | 040cfc89b9a110cd0fb2abdcd35e8215b4a71f60 (diff) |
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]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2502
Diffstat (limited to 'vm_args.c')
-rw-r--r-- | vm_args.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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); |