mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Do not apply anon_rest optimization when passed array uses keyword-flagged hash
The optimization sets args->rest_dupped to avoid allocating an array, but this is not safe if the splat array ends in a keyword flagged hash. Unset args->rest_dupped in this case. Fixes [Bug #20388]
This commit is contained in:
parent
a2ac28d8ab
commit
2dbcc123f4
2 changed files with 16 additions and 0 deletions
|
@ -687,6 +687,9 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
|
|||
rest_last = rb_hash_dup(rest_last);
|
||||
kw_flag |= VM_CALL_KW_SPLAT | VM_CALL_KW_SPLAT_MUT;
|
||||
|
||||
// Unset rest_dupped set by anon_rest as we may need to modify splat in this case
|
||||
args->rest_dupped = false;
|
||||
|
||||
if (ignore_keyword_hash_p(rest_last, iseq, &kw_flag, &converted_keyword_hash)) {
|
||||
arg_rest_dup(args);
|
||||
rb_ary_pop(args->rest);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue