ruby-changes:57633
From: Jeremy <ko1@a...>
Date: Sat, 7 Sep 2019 12:20:16 +0900 (JST)
Subject: [ruby-changes:57633] 5603681520 (master): Enable keyword argument warnings when called from C
https://git.ruby-lang.org/ruby.git/commit/?id=5603681520 From 56036815207b803151b0c7215da3a880bbad6df1 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Fri, 6 Sep 2019 13:35:50 -0700 Subject: Enable keyword argument warnings when called from C Previously, Ruby did not warn in these cases, and in some cases did not have the same behavior. This makes calls from C handled the same way as calls from Ruby. diff --git a/vm_args.c b/vm_args.c index 1542607..7ffc756 100644 --- a/vm_args.c +++ b/vm_args.c @@ -786,7 +786,7 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co https://github.com/ruby/ruby/blob/trunk/vm_args.c#L786 (kw_splat && given_argc > max_argc)) && args->kw_argv == NULL) { if (given_argc > min_argc) { - if (((kw_flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT)) || !ec->cfp->iseq /* called from C */)) { + if (kw_flag) { int check_only_symbol = (kw_flag & VM_CALL_KW_SPLAT) && iseq->body->param.flags.has_kw && !iseq->body->param.flags.has_kwrest; @@ -808,13 +808,10 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co https://github.com/ruby/ruby/blob/trunk/vm_args.c#L808 * def foo(k:1) p [k]; end * foo({k:42}) #=> 42 */ - if (ec->cfp->iseq) { - /* called from Ruby level */ - rb_warn_last_hash_to_keyword(calling, ci, iseq); - } + rb_warn_last_hash_to_keyword(calling, ci, iseq); given_argc--; } - else if (keyword_hash != Qnil && ec->cfp->iseq) { + else if (keyword_hash != Qnil) { rb_warn_split_last_hash_to_keyword(calling, ci, iseq); } } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/