vm.c: change the default error message for undefined super method.

- (old) `undefined method 'foo'`
- (new) `no superclass method 'foo'`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-04-01 08:42:30 +09:00
parent d5a4d5e393
commit bda242a135
3 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -520,7 +520,7 @@ mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args)
* r.xxiii #=> 23
* r.mm #=> 2000
*/
static mrb_value
mrb_value
mrb_obj_missing(mrb_state *mrb, mrb_value mod)
{
mrb_sym name;
+7 -2
View File
@@ -1068,6 +1068,7 @@ check_target_class(mrb_state *mrb)
return TRUE;
}
mrb_value mrb_obj_missing(mrb_state *mrb, mrb_value mod);
void mrb_hash_check_kdict(mrb_state *mrb, mrb_value self);
mrb_int mrb_div_int(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_float mrb_div_flo(mrb_float x, mrb_float y);
@@ -1670,13 +1671,17 @@ RETRY_TRY_BLOCK:
if (MRB_METHOD_UNDEF_P(m)) {
mrb_sym missing = MRB_SYM(method_missing);
if (mrb_func_basic_p(mrb, recv, missing, mrb_obj_missing)) {
mrb_value args = (argc < 0) ? regs[a+1] : mrb_ary_new_from_values(mrb, b, regs+a+1);
mrb_no_method_error(mrb, mid, args, "no superclass method '%n'", mid);
}
if (mid != missing) {
cls = mrb_class(mrb, recv);
}
m = mrb_method_search_vm(mrb, &cls, missing);
if (MRB_METHOD_UNDEF_P(m)) {
if (MRB_METHOD_UNDEF_P(m)) { /* just in case */
mrb_value args = (argc < 0) ? regs[a+1] : mrb_ary_new_from_values(mrb, b, regs+a+1);
mrb_method_missing(mrb, mid, recv, args);
mrb_method_missing(mrb, missing, recv, args);
}
mid = missing;
if (argc >= 0) {