summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 01:40:15 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 01:40:15 (GMT)
commit0ba049256e1b8b17f68c45266396ed1e3976481b (patch)
tree401a744bf49a200f1cd80a27e26ff5264107deaf /range.c
parentbb2aa9b3434cc92dd7acf40ce26d12672aaf6597 (diff)
range.c: check if exclude_end? is defined
* range.c (rb_range_values): should raise TypeError if necessary method is not defined, not NoMethodError, when trying to tell if the object is a Range and extract info. [ruby-core:83541] [Bug #14048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/range.c b/range.c
index ba96e3d..dbb3dcb 100644
--- a/range.c
+++ b/range.c
@@ -987,11 +987,22 @@ rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
excl = EXCL(range);
}
else {
+ VALUE x;
+#if 0
+ /* TODO: fix spec/mspec/lib/mspec/mocks/mock.rb:Mock.verify_call */
+ b = rb_check_funcall(range, id_beg, 0, 0);
+ if (b == Qundef) return (int)Qfalse;
+ e = rb_check_funcall(range, id_end, 0, 0);
+ if (e == Qundef) return (int)Qfalse;
+#else
if (!rb_respond_to(range, id_beg)) return (int)Qfalse;
if (!rb_respond_to(range, id_end)) return (int)Qfalse;
b = rb_funcall(range, id_beg, 0);
e = rb_funcall(range, id_end, 0);
- excl = RTEST(rb_funcall(range, rb_intern("exclude_end?"), 0));
+#endif
+ x = rb_check_funcall(range, rb_intern("exclude_end?"), 0, 0);
+ if (x == Qundef) return (int)Qfalse;
+ excl = RTEST(x);
}
*begp = b;
*endp = e;