Bug #16522 ยป scan-args-deprecated-warn-16522.patch
class.c | ||
---|---|---|
VALUE *tmp_buffer;
|
||
};
|
||
static void
|
||
warn_deprecated(const char *msg)
|
||
{
|
||
if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_DEPRECATED)) {
|
||
rb_warn(msg);
|
||
}
|
||
}
|
||
static void
|
||
rb_scan_args_parse(int kw_flag, int argc, const VALUE *argv, const char *fmt, struct rb_scan_args_t *arg)
|
||
{
|
||
... | ... | |
not specified and arguments are given more than sufficient.
|
||
This will be removed in Ruby 3. */
|
||
if (!arg->f_var && arg->n_mand + arg->n_opt < argc) {
|
||
rb_warn("The last argument is nil, treating as empty keywords");
|
||
warn_deprecated("The last argument is nil, treating as empty keywords");
|
||
argc--;
|
||
}
|
||
}
|
||
... | ... | |
if (!keyword_given && !last_hash_keyword) {
|
||
/* Warn if treating positional as keyword, as in Ruby 3,
|
||
this will be an error */
|
||
rb_warn("Using the last argument as keyword parameters is deprecated");
|
||
warn_deprecated("Using the last argument as keyword parameters is deprecated");
|
||
}
|
||
argc--;
|
||
}
|
||
else {
|
||
/* Warn if splitting either positional hash to keywords or keywords
|
||
to positional hash, as in Ruby 3, no splitting will be done */
|
||
rb_warn("The last argument is split into positional and keyword parameters");
|
||
warn_deprecated("The last argument is split into positional and keyword parameters");
|
||
arg->last_idx = argc - 1;
|
||
}
|
||
arg->hash = opts ? opts : Qnil;
|
||
... | ... | |
}
|
||
else if (arg->f_hash && keyword_given && arg->n_mand == argc) {
|
||
/* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
|
||
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
|
||
warn_deprecated("Passing the keyword argument as the last hash parameter is deprecated");
|
||
}
|
||
}
|
||
if (arg->f_hash && arg->n_mand == argc+1 && empty_keyword_given) {
|
||
... | ... | |
ptr[argc] = rb_hash_new();
|
||
argc++;
|
||
*(&argv) = ptr;
|
||
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
|
||
warn_deprecated("Passing the keyword argument as the last hash parameter is deprecated");
|
||
}
|
||
arg->argc = argc;
|
error.c | ||
---|---|---|
return exc;
|
||
}
|
||
static unsigned int warning_disabled_categories;
|
||
unsigned int warning_disabled_categories;
|
||
static unsigned int
|
||
rb_warning_category_mask(VALUE category)
|
include/ruby/ruby.h | ||
---|---|---|
int f_var, int f_hash, int f_block,
|
||
VALUE *vars[], char *fmt, int varc));
|
||
extern unsigned int warning_disabled_categories;
|
||
/* 1: RB_WARN_CATEGORY_DEPRECATED */
|
||
#define WARN_DEPRECATED(msg) \
|
||
if (!(warning_disabled_categories & 1)) { \
|
||
rb_warn(msg); \
|
||
}
|
||
inline int
|
||
rb_scan_args_set(int argc, const VALUE *argv,
|
||
int n_lead, int n_opt, int n_trail,
|
||
... | ... | |
not specified and arguments are given more than sufficient.
|
||
This will be removed in Ruby 3. */
|
||
if (!f_var && n_mand + n_opt < argc) {
|
||
rb_warn("The last argument is nil, treating as empty keywords");
|
||
WARN_DEPRECATED("The last argument is nil, treating as empty keywords");
|
||
argc--;
|
||
}
|
||
}
|
||
... | ... | |
if (!keyword_given) {
|
||
/* Warn if treating positional as keyword, as in Ruby 3,
|
||
this will be an error */
|
||
rb_warn("Using the last argument as keyword parameters is deprecated");
|
||
WARN_DEPRECATED("Using the last argument as keyword parameters is deprecated");
|
||
}
|
||
argc--;
|
||
}
|
||
else {
|
||
/* Warn if splitting either positional hash to keywords or keywords
|
||
to positional hash, as in Ruby 3, no splitting will be done */
|
||
rb_warn("The last argument is split into positional and keyword parameters");
|
||
WARN_DEPRECATED("The last argument is split into positional and keyword parameters");
|
||
last_idx = argc - 1;
|
||
}
|
||
hash = opts ? opts : Qnil;
|
||
... | ... | |
}
|
||
else if (f_hash && keyword_given && n_mand == argc) {
|
||
/* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
|
||
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
|
||
WARN_DEPRECATED("Passing the keyword argument as the last hash parameter is deprecated");
|
||
}
|
||
}
|
||
if (f_hash && n_mand > 0 && n_mand == argc+1 && empty_keyword_given) {
|
||
... | ... | |
ptr[argc] = rb_hash_new();
|
||
argc++;
|
||
*(&argv) = ptr;
|
||
rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
|
||
WARN_DEPRECATED("Passing the keyword argument as the last hash parameter is deprecated");
|
||
}
|
||