Do not include object string representation in `NoMethodError` message.

This information is not mandatory but causes a lot of problems in the
past due to infinite recursion by redefining `to_str`, `inspect` etc.
parent ca0f32a2
...@@ -956,26 +956,7 @@ mrb_obj_remove_instance_variable(mrb_state *mrb, mrb_value self) ...@@ -956,26 +956,7 @@ mrb_obj_remove_instance_variable(mrb_state *mrb, mrb_value self)
void void
mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args) mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args)
{ {
mrb_sym inspect; mrb_no_method_error(mrb, name, args, "undefined method '%S'", mrb_sym2str(mrb, name));
mrb_value repr;
inspect = mrb_intern_lit(mrb, "inspect");
if (mrb->c->ci > mrb->c->cibase && mrb->c->ci[-1].mid == inspect) {
/* method missing in inspect; avoid recursion */
repr = mrb_any_to_s(mrb, self);
}
else if (mrb_respond_to(mrb, self, inspect) && mrb->c->ci - mrb->c->cibase < 16) {
repr = mrb_funcall_argv(mrb, self, inspect, 0, 0);
if (mrb_string_p(repr) && RSTRING_LEN(repr) > 64) {
repr = mrb_any_to_s(mrb, self);
}
}
else {
repr = mrb_any_to_s(mrb, self);
}
mrb_no_method_error(mrb, name, args, "undefined method '%S' for %S",
mrb_sym2str(mrb, name), repr);
} }
/* 15.3.1.3.30 */ /* 15.3.1.3.30 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment