diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-09-08 20:51:56 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-09-08 22:47:06 -0700 |
commit | 61d90da25c027f896ddc0e71c7b17c67d4b12a97 (patch) | |
tree | 00f79e30acd34f270132d719e2e5ffaf66fa323c /vm_args.c | |
parent | 6382f5cc91ac9e36776bc854632d9a1237250da7 (diff) |
Fix invalid keyword argument separation warning for delegating calls
This removes an invalid keyword argument separation warning for
code such as:
```ruby
def foo(arg)
arg
end
kw = {}
foo(*[1], **kw)
```
This warning was caused because the remove_empty_keyword_hash
was set based on a comparison with two variables, and in this
case, one of the variables was updated after the check and we
need to use the updated variable.
Simplify things by just inlining the comparison.
Diffstat (limited to 'vm_args.c')
-rw-r--r-- | vm_args.c | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -654,7 +654,6 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co VALUE keyword_hash = Qnil; VALUE * const orig_sp = ec->cfp->sp; unsigned int i; - int remove_empty_keyword_hash = 1; vm_check_canary(ec, orig_sp); /* @@ -704,10 +703,6 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co args->kw_argv = NULL; } - if (given_argc == min_argc) { - remove_empty_keyword_hash = 0; - } - if (ci->flag & VM_CALL_ARGS_SPLAT) { args->rest = locals[--args->argc]; args->rest_index = 0; @@ -715,7 +710,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co if (kw_flag & VM_CALL_KW_SPLAT) { int len = RARRAY_LENINT(args->rest); if (len > 0 && ignore_keyword_hash_p(RARRAY_AREF(args->rest, len - 1), iseq)) { - if (remove_empty_keyword_hash) { + if (given_argc != min_argc) { arg_rest_dup(args); rb_ary_pop(args->rest); given_argc--; @@ -730,7 +725,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co else { if (kw_flag & VM_CALL_KW_SPLAT) { if (ignore_keyword_hash_p(args->argv[args->argc-1], iseq)) { - if (remove_empty_keyword_hash) { + if (given_argc != min_argc) { args->argc--; given_argc--; kw_flag &= ~VM_CALL_KW_SPLAT; |