mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
object.c: improve handling of the broken inspect method.
When `inspect` method returns non-string value, it will return a string given from `to_s` (and if `to_s` fails, will raise an exception).
This commit is contained in:
+5
-1
@@ -606,7 +606,11 @@ mrb_check_hash_type(mrb_state *mrb, mrb_value hash)
|
||||
MRB_API mrb_value
|
||||
mrb_inspect(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
return mrb_obj_as_string(mrb, mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0));
|
||||
mrb_value v = mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0);
|
||||
if (!mrb_string_p(v)) {
|
||||
v = mrb_obj_as_string(mrb, obj);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
MRB_API mrb_bool
|
||||
|
||||
Reference in New Issue
Block a user