vm.c: change the default error message for undefined `super` method.
(old) `undefined method 'foo'`
(new) `no superclass method 'foo'`
MODIFY
src/kernel.c
src/kernel.c
@@ -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;

MODIFY
src/vm.c
src/vm.c
@@ -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) {

MODIFY
test/t/kernel.rb
test/t/kernel.rb
@@ -346,7 +346,7 @@ assert('Kernel#method_missing', '15.3.1.3.30') do
end
end
no_super_test = NoSuperMethodTestClass.new
- msg = "undefined method 'no_super_method_named_this'"
+ msg = "no superclass method 'no_super_method_named_this'"
assert_raise_with_message(NoMethodError, msg) do
no_super_test.no_super_method_named_this
end

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

- (old) `undefined method 'foo'`
- (new) `no superclass method 'foo'`