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 | 9a51fecc55dca8f4feb0b558c048532d5f5b1f3e (patch) | |
| tree | 0ed5e86f76f9adff8eb848d6be67500adb86edd2 /object.c | |
| parent | 4e2edd1992f7dc775e430547cc4cec28f2bd1035 (diff) | |
| download | ruby-9a51fecc55dca8f4feb0b558c048532d5f5b1f3e.tar.gz ruby-9a51fecc55dca8f4feb0b558c048532d5f5b1f3e.tar.xz ruby-9a51fecc55dca8f4feb0b558c048532d5f5b1f3e.zip | |
matz
git-svn-id: http://svn.ruby-lang.org/repos/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; } |
