Commit f7313b60 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge branch 'fix-type-error-message' of https://github.com/h2so5/mruby into...

Merge branch 'fix-type-error-message' of https://github.com/h2so5/mruby into h2so5-fix-type-error-message
parents cf7fb881 1f571dd5
...@@ -20,7 +20,7 @@ class Array ...@@ -20,7 +20,7 @@ class Array
end end
def -(elem) def -(elem)
raise TypeError, "can't convert to Array" unless elem.class == Array raise TypeError, "can't convert #{elem.class.to_s} into Array" unless elem.class == Array
hash = {} hash = {}
array = [] array = []
...@@ -30,14 +30,14 @@ class Array ...@@ -30,14 +30,14 @@ class Array
end end
def |(elem) def |(elem)
raise TypeError, "can't convert to Array" unless elem.class == Array raise TypeError, "can't convert #{elem.class.to_s} into Array" unless elem.class == Array
ary = self + elem ary = self + elem
ary.uniq! or ary ary.uniq! or ary
end end
def &(elem) def &(elem)
raise TypeError, "can't convert to Array" unless elem.class == Array raise TypeError, "can't convert #{elem.class.to_s} into Array" unless elem.class == Array
hash = {} hash = {}
array = [] array = []
......
...@@ -305,7 +305,9 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *metho ...@@ -305,7 +305,9 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *metho
m = mrb_intern(mrb, method); m = mrb_intern(mrb, method);
if (!mrb_respond_to(mrb, val, m)) { if (!mrb_respond_to(mrb, val, m)) {
if (raise) { if (raise) {
mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %S into %S", val, mrb_str_new_cstr(mrb, tname)); const char *cname = mrb_obj_classname(mrb, val);
mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %S into %S",
mrb_str_new_cstr(mrb, cname), mrb_str_new_cstr(mrb, tname));
return mrb_nil_value(); return mrb_nil_value();
} }
else { else {
......
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