mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_args.c: make the keyword deprecation message helpful
``` $ ./miniruby -e 'def foo(kw: 1); end; h = {kw: 1}; foo(h)' -e:1: warning: The last argument is used as the keyword parameter -e:1: warning: for `foo' defined here; maybe ** should be added to the call? ```
This commit is contained in:
parent
409e4ab740
commit
a1f98cd4c1
1 changed files with 3 additions and 3 deletions
|
@ -693,18 +693,18 @@ rb_warn_last_hash_to_keyword(rb_execution_context_t * const ec, struct rb_callin
|
||||||
name = rb_id2str(ci->mid);
|
name = rb_id2str(ci->mid);
|
||||||
loc = rb_iseq_location(iseq);
|
loc = rb_iseq_location(iseq);
|
||||||
if (NIL_P(loc)) {
|
if (NIL_P(loc)) {
|
||||||
rb_warn("The last argument for `%"PRIsVALUE"' is used as the keyword parameter",
|
rb_warn("The last argument for `%"PRIsVALUE"' is used as the keyword parameter; maybe ** should be added to the call?",
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_warn("The last argument is used as the keyword parameter");
|
rb_warn("The last argument is used as the keyword parameter");
|
||||||
if (calling->recv != Qundef) {
|
if (calling->recv != Qundef) {
|
||||||
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
|
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
|
||||||
"for `%"PRIsVALUE"' defined here", name);
|
"for `%"PRIsVALUE"' defined here; maybe ** should be added to the call?", name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
|
rb_compile_warn(RSTRING_PTR(RARRAY_AREF(loc, 0)), FIX2INT(RARRAY_AREF(loc, 1)),
|
||||||
"for method defined here");
|
"for method defined here; maybe ** should be added to the call?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue