summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/compar.c b/compar.c
index 0a5a10ee23..bb90125bff 100644
--- a/compar.c
+++ b/compar.c
@@ -30,13 +30,25 @@ rb_cmpint(val)
return 0;
}
-static VALUE
-cmperr()
+void
+rb_cmperr(x, y)
+ VALUE x, y;
{
- rb_raise(rb_eArgError, "comparison failed");
- return Qnil; /* not reached */
+ const char *classname;
+
+ if (SPECIAL_CONST_P(y)) {
+ y = rb_inspect(y);
+ classname = StringValuePtr(y);
+ }
+ else {
+ classname = rb_obj_classname(y);
+ }
+ rb_raise(rb_eArgError, "comparison of %s to %s failed",
+ rb_obj_classname(x), classname);
}
+#define cmperr() (rb_cmperr(x, y), Qnil)
+
static VALUE
cmp_equal(x, y)
VALUE x, y;