Project

General

Profile

Bug #13196 ยป missing_kwargs.diff

olivierlacan (Olivier Lacan), 02/26/2017 03:26 AM

View differences:

vm_args.c
725 725
static void
726 726
argument_arity_error(rb_thread_t *th, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc)
727 727
{
728
    raise_argument_error(th, iseq, rb_arity_error_new(miss_argc, min_argc, max_argc));
728
    VALUE exc = rb_arity_error_new(miss_argc, min_argc, max_argc);
729
    if (iseq->body->param.flags.has_kw) {
730
   const struct rb_iseq_param_keyword *const kw = iseq->body->param.keyword;
731
   const ID *keywords = kw->table;
732
   int req_key_num = kw->required_num;
733
   if (req_key_num > 0) {
734
       VALUE mesg = rb_attr_get(exc, idMesg);
735
       rb_str_resize(mesg, RSTRING_LEN(mesg)-1);
736
       rb_str_cat_cstr(mesg, "; required keyword");
737
       if (req_key_num > 1) rb_str_cat_cstr(mesg, "s");
738
       do {
739
       rb_str_cat_cstr(mesg, ": ");
740
       rb_str_append(mesg, rb_id2str(*keywords++));
741
       rb_str_cat_cstr(mesg, ",");
742
       } while (--req_key_num);
743
       RSTRING_PTR(mesg)[RSTRING_LEN(mesg)-1] = ')';
744
   }
745
    }
746
    raise_argument_error(th, iseq, exc);
729 747
}
730 748
static void