Reimplement `Exception#message` in Ruby
Suppresses the possibility of `mrb_vm_exec()` being called recursively.
MODIFY
mrblib/10error.rb
mrblib/10error.rb
+class Exception
+ ##
+ # call-seq:
+ # exception.message -> string
+ #
+ # Returns the result of invoking <code>exception.to_s</code>.
+ # Normally this returns the exception's message or name.
+ #
+ def message
+ to_s
+ end
+end
+
# ISO 15.2.24
class ArgumentError < StandardError
end

MODIFY
src/error.c
src/error.c
@@ -136,20 +136,6 @@ exc_to_s(mrb_state *mrb, mrb_value exc)
return mesg;
}
-/*
- * call-seq:
- * exception.message -> string
- *
- * Returns the result of invoking <code>exception.to_s</code>.
- * Normally this returns the exception's message or name.
- */
-
-static mrb_value
-exc_message(mrb_state *mrb, mrb_value exc)
-{
- return mrb_funcall_id(mrb, exc, MRB_SYM(to_s), 0);
-}
-
/*
* call-seq:
* exception.inspect -> string
@@ -667,7 +653,6 @@ mrb_init_exception(mrb_state *mrb)
mrb_define_method(mrb, exception, "exception", exc_exception, MRB_ARGS_OPT(1));
mrb_define_method(mrb, exception, "initialize", exc_initialize, MRB_ARGS_OPT(1));
mrb_define_method(mrb, exception, "to_s", exc_to_s, MRB_ARGS_NONE());
- mrb_define_method(mrb, exception, "message", exc_message, MRB_ARGS_NONE());
mrb_define_method(mrb, exception, "inspect", mrb_exc_inspect, MRB_ARGS_NONE());
mrb_define_method(mrb, exception, "backtrace", mrb_exc_backtrace, MRB_ARGS_NONE());
mrb_define_method(mrb, exception, "set_backtrace", exc_set_backtrace, MRB_ARGS_REQ(1));

Reimplement `Exception#message` in Ruby

Suppresses the possibility of `mrb_vm_exec()` being called recursively.