summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 07:17:20 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-03 07:17:20 (GMT)
commit4b4d364e5228a42eef3f086c01a7067680fd1f6a (patch)
treeb775308a9d99b389b5011dbc654a8fb3b78a1a81 /random.c
parent002f6ea856f14d516b8e5e9c8d15f38240ece738 (diff)
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
Diffstat (limited to 'random.c')
-rw-r--r--random.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/random.c b/random.c
index 75ad5ff..4efe174 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;