mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Correctly set anon_kwrest flag for def f(b: 1, **)
In cases where a method accepts both keywords and an anonymous keyword splat, the method was not marked as taking an anonymous keyword splat. Fix that in the compiler. Doing that broke handling of nil keyword splats in yjit, so update yjit to handle that. Add a test to check that calling a method that accepts both a keyword argument and an anonymous keyword splat does not modify a passed keyword splat hash. Move the anon_kwrest check from setup_parameters_complex to ignore_keyword_hash_p, and only use it if the keyword hash is already a hash. This should speed things up slightly as it avoids a check previously used for all callers of setup_parameters_complex. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
This commit is contained in:
parent
6da8f04e01
commit
99384bac28
4 changed files with 16 additions and 7 deletions
|
@ -1976,8 +1976,11 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
|
|||
keyword->num = kw;
|
||||
|
||||
if (RNODE_DVAR(args->kw_rest_arg)->nd_vid != 0) {
|
||||
ID kw_id = iseq->body->local_table[arg_size];
|
||||
keyword->rest_start = arg_size++;
|
||||
body->param.flags.has_kwrest = TRUE;
|
||||
|
||||
if (kw_id == idPow) body->param.flags.anon_kwrest = TRUE;
|
||||
}
|
||||
keyword->required_num = rkw;
|
||||
keyword->table = &body->local_table[keyword->bits_start - keyword->num];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue