From 4b4d364e5228a42eef3f086c01a7067680fd1f6a Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 3 Aug 2018 07:17:20 +0000 Subject: [PATCH] random.c: moved domain error * random.c (rand_range): moved call of domain_error(), not to raise an exception in range_values(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- random.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/random.c b/random.c index 75ad5ff5bd..4efe174da9 100644 --- a/random.c +++ b/random.c @@ -1164,7 +1164,7 @@ range_values(VALUE vmax, VALUE *begp, VALUE *endp, int *exclp) if (!rb_range_values(vmax, begp, &end, exclp)) return Qfalse; if (endp) *endp = end; - if (NIL_P(end)) domain_error(); + if (NIL_P(end)) return Qnil; if (!rb_respond_to(end, id_minus)) return Qfalse; r = rb_funcallv(end, id_minus, 1, begp); if (NIL_P(r)) return Qfalse; @@ -1252,6 +1252,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range) if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse) return Qfalse; + if (NIL_P(v)) domain_error(); if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_int(vmax), !NIL_P(v))) { long max; vmax = v;