mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* error.c (exc_equal): duck typing equal to make it transitive.
[ruby-dev:34880] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cad0fbddf8
commit
00856f76f7
2 changed files with 16 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Dec 19 07:45:37 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* error.c (exc_equal): duck typing equal to make it transitive.
|
||||
[ruby-dev:34880]
|
||||
|
||||
Thu Dec 18 19:31:54 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* lib/irb/init.rb (IRB.opt_parse): (M17N) adds -U and -E as command
|
||||
|
|
15
error.c
15
error.c
|
@ -554,15 +554,22 @@ exc_set_backtrace(VALUE exc, VALUE bt)
|
|||
static VALUE
|
||||
exc_equal(VALUE exc, VALUE obj)
|
||||
{
|
||||
VALUE mesg, backtrace;
|
||||
ID id_mesg;
|
||||
|
||||
if (exc == obj) return Qtrue;
|
||||
if (rb_obj_class(exc) != rb_obj_class(obj))
|
||||
return Qfalse;
|
||||
CONST_ID(id_mesg, "mesg");
|
||||
if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
|
||||
if (rb_obj_class(exc) != rb_obj_class(obj)) {
|
||||
mesg = rb_funcall(obj, rb_intern("message"), 0, 0);
|
||||
backtrace = rb_funcall(obj, rb_intern("backtrace"), 0, 0);
|
||||
}
|
||||
else {
|
||||
mesg = rb_attr_get(obj, id_mesg);
|
||||
backtrace = exc_backtrace(obj);
|
||||
}
|
||||
if (!rb_equal(rb_attr_get(exc, id_mesg), mesg))
|
||||
return Qfalse;
|
||||
if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
|
||||
if (!rb_equal(exc_backtrace(exc), backtrace))
|
||||
return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue