aboutsummaryrefslogtreecommitdiffstats
path: root/vm_args.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2023-07-10 10:06:23 -0700
committerGitHub <noreply@github.com>2023-07-10 10:06:23 -0700
commit3874381c4483ba7794ac2abf157e265546f9bfa7 (patch)
treed02850a4e81c80e44137c6cfc8c992a2538eb61d /vm_args.c
parent53c560156542915938ebebeac3e12352c04feb24 (diff)
downloadruby-3874381c4483ba7794ac2abf157e265546f9bfa7.tar.gz
Fix autosplat conditions to handle ruby2_keywords case
Autosplat should not occur if there are two arguments but second argument is an array containing a ruby2_keywords splat. Only autosplat if a single argument to be yielded to the block, and there is no splatted flagged keyword hash passed. Fixes [Bug #19759]
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 cc7f1e29b5..6832849e1e 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -640,8 +640,9 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
case arg_setup_method:
break; /* do nothing special */
case arg_setup_block:
- if (given_argc == (NIL_P(keyword_hash) ? 1 : 2) &&
+ if (given_argc == 1 &&
allow_autosplat &&
+ !splat_flagged_keyword_hash &&
(min_argc > 0 || ISEQ_BODY(iseq)->param.opt_num > 1) &&
!ISEQ_BODY(iseq)->param.flags.ambiguous_param0 &&
!((ISEQ_BODY(iseq)->param.flags.has_kw ||