diff options
author | Jeremy Evans <[email protected]> | 2022-03-30 11:03:56 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-30 11:03:56 -0700 |
commit | fbaadd1cfe7fbfd1b904f193f99d7c845a6ed804 (patch) | |
tree | 298c1393d770cc229d731b43ac13c793dcd93a36 /vm_args.c | |
parent | 75efbb98afe854972a1c832ec5d4d66639c41c74 (diff) |
Do not autosplat array in block call just because keywords accepted
If the block only accepts a single positional argument plus keywords,
then do not autosplat. Still autosplat if the block accepts more
than one positional argument in addition to keywords.
Autosplatting a single positional argument plus keywords made sense
in Ruby 2, since a final positional hash could be used as keywords,
but it does not make sense in Ruby 3.
Fixes [Bug #18633]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5665
Merged-By: jeremyevans <[email protected]>
Diffstat (limited to 'vm_args.c')
-rw-r--r-- | vm_args.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -599,7 +599,6 @@ 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 */ @@ -608,6 +607,9 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co allow_autosplat && (min_argc > 0 || ISEQ_BODY(iseq)->param.opt_num > 1) && !ISEQ_BODY(iseq)->param.flags.ambiguous_param0 && + !((ISEQ_BODY(iseq)->param.flags.has_kw || + ISEQ_BODY(iseq)->param.flags.has_kwrest) + && max_argc == 1) && args_check_block_arg0(args)) { given_argc = RARRAY_LENINT(args->rest); } |