aboutsummaryrefslogtreecommitdiffstats
path: root/compar.c
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-11 19:33:46 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-11 19:33:46 +0000
commita1992e25b91d77866cd32f4b16fb666f5e89adf5 (patch)
tree01aaa9f1441d20e8b742ffa3fe41438837058835 /compar.c
parentecbc694f4458fd6a434dab299bcf3bc5f2499fc9 (diff)
downloadruby-a1992e25b91d77866cd32f4b16fb666f5e89adf5.tar.gz
* compar.c (cmp_equal): no more error hiding for Comparable#==.
It now behaves as other Comparable methods. See #7688. * test/ruby/test_comparable.rb: update related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/compar.c b/compar.c
index 3d0a3e81dc..6eb34ed794 100644
--- a/compar.c
+++ b/compar.c
@@ -57,24 +57,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)
-{
- rb_warn("Comparable#== will no more rescue exceptions of #<=> in the next release.");
- rb_warn("Return nil in #<=> if the comparison is inappropriate or avoid such comparison.");
- return Qfalse;
-}
-
/*
* call-seq:
* obj == other -> true or false
@@ -90,12 +72,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;
}
/*