diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-08-31 05:29:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-08-31 05:29:54 +0000 |
commit | e0009b6a5437c5427a6abf3ddeee3804f73b9870 (patch) | |
tree | 0ed5e86f76f9adff8eb848d6be67500adb86edd2 /object.c | |
parent | 5b3ed19660ef4d9ea87265416a199e7dc7e940c1 (diff) |
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -853,8 +853,12 @@ rb_convert_type(val, type, tname, method) arg1.val = arg2.val = val; arg1.s = method; arg2.s = tname; - val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2); - Check_Type(val, type); + val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2, + rb_eStandardError, rb_eNameError, 0); + if (TYPE(val) != type) { + rb_raise(rb_eTypeError, "%s#%s should return %s", + rb_class2name(CLASS_OF(arg1.val)), method, tname); + } return val; } @@ -888,9 +892,11 @@ rb_Integer(val) arg1.val = arg2.val = val; arg1.s = "to_i"; arg2.s = "Integer"; - val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2); + val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2, + rb_eStandardError, rb_eNameError, 0); if (!rb_obj_is_kind_of(val, rb_cInteger)) { - rb_raise(rb_eTypeError, "to_i should return Integer"); + rb_raise(rb_eTypeError, "%s#to_i should return Integer", + rb_class2name(CLASS_OF(arg1.val))); } return val; } |