summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-05 11:14:59 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-05 11:14:59 +0000
commitd781caaf313b8649948c107bba277e5ad7307314 (patch)
tree4e4fb90e51b5c234883bc7fb4e0cbeb983e9bfa4 /compar.c
parent306c154c2d0010cebd600175f3f70083fc787599 (diff)
downloadruby-d781caaf313b8649948c107bba277e5ad7307314.tar.gz
* compar.c (cmp_equal): remove error hiding in Comparable#==.
Comparable#== no longer rescues exceptions silently. This was the cause of quite a couple bugs. See #7688. [EXPERIMENTAL] * test/ruby/test_comparable.rb: adapt assertion to match new behavior. * lib/rdoc/method_attr.rb: fix bugs discovered by this change. * test/rdoc/test_rdoc_normal_class.rb: fix bugs in tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/compar.c b/compar.c
index fa638eeb79..8ce5c54287 100644
--- a/compar.c
+++ b/compar.c
@@ -58,22 +58,6 @@ cmp_eq_recursive(VALUE arg1, VALUE arg2, int recursive)
return rb_funcallv(arg1, cmp, 1, &arg2);
}
-static VALUE
-cmp_eq(VALUE *a)
-{
- VALUE c = rb_exec_recursive_paired_outer(cmp_eq_recursive, a[0], a[1], a[1]);
-
- if (NIL_P(c)) return Qfalse;
- if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
- return Qfalse;
-}
-
-static VALUE
-cmp_failed(void)
-{
- return Qfalse;
-}
-
/*
* call-seq:
* obj == other -> true or false
@@ -89,12 +73,14 @@ cmp_failed(void)
static VALUE
cmp_equal(VALUE x, VALUE y)
{
- VALUE a[2];
-
+ VALUE c;
if (x == y) return Qtrue;
- a[0] = x; a[1] = y;
- return rb_rescue(cmp_eq, (VALUE)a, cmp_failed, 0);
+ c = rb_exec_recursive_paired_outer(cmp_eq_recursive, x, y, y);
+
+ if (NIL_P(c)) return Qfalse;
+ if (rb_cmpint(c, x, y) == 0) return Qtrue;
+ return Qfalse;
}
/*