From 698a24674eb0707fdc8d934084932e845db955cd Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 8 May 2003 03:56:12 +0000 Subject: * compar.c (rb_cmperr): raise comparison failure. * intern.h: prototype; rb_cmperr * numeric.c (flo_gt, flo_ge, flo_lt, flo_le, fix_gt, fix_ge, fix_lt, fix_le): should fail unless the argument is comparable. (ruby-bugs-ja:PR#456) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compar.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'compar.c') 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; -- cgit v1.2.3