From ead61f4ac85a2bf0fffa436dd034812bbfb5738d Mon Sep 17 00:00:00 2001 From: eregon Date: Tue, 25 Apr 2017 11:42:43 +0000 Subject: no longer rescue exceptions of #<=> when initializing a Range * range.c (range_init): no longer hide the user exception with a ArgumentError, just let the user exception go through. * test/ruby/test_range.rb (test_new): add tests. [Feature #7688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- range.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'range.c') diff --git a/range.c b/range.c index 422ed29f15..837fdb5d9c 100644 --- a/range.c +++ b/range.c @@ -34,19 +34,6 @@ static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE); #define EXCL(r) RTEST(RANGE_EXCL(r)) -static VALUE -range_failed(void) -{ - rb_raise(rb_eArgError, "bad value for range"); - return Qnil; /* dummy */ -} - -static VALUE -range_check(VALUE *args) -{ - return rb_funcall(args[0], id_cmp, 1, args[1]); -} - static void range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end) { @@ -58,9 +45,9 @@ range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end) if (!FIXNUM_P(beg) || !FIXNUM_P(end)) { VALUE v; - v = rb_rescue(range_check, (VALUE)args, range_failed, 0); + v = rb_funcall(beg, id_cmp, 1, end); if (NIL_P(v)) - range_failed(); + rb_raise(rb_eArgError, "bad value for range"); } RANGE_SET_EXCL(range, exclude_end); -- cgit v1.2.3