summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--enumerator.c2
-rw-r--r--internal.h1
-rw-r--r--range.c3
-rw-r--r--test/ruby/test_array.rb1
4 files changed, 6 insertions, 1 deletions
diff --git a/enumerator.c b/enumerator.c
index 338a9e7584..021daeba59 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -169,7 +169,7 @@ struct enum_chain {
long pos;
};
-static VALUE rb_cArithSeq;
+VALUE rb_cArithSeq;
/*
* Enumerator
diff --git a/internal.h b/internal.h
index b62feb9cf1..433ab6635d 100644
--- a/internal.h
+++ b/internal.h
@@ -1414,6 +1414,7 @@ void rb_encdb_set_unicode(int index);
PUREFUNC(int rb_data_is_encoding(VALUE obj));
/* enum.c */
+extern VALUE rb_cArithSeq;
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary);
diff --git a/range.c b/range.c
index dab8314400..ac9affd872 100644
--- a/range.c
+++ b/range.c
@@ -1141,6 +1141,9 @@ rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp)
e = RANGE_END(range);
excl = EXCL(range);
}
+ else if (RTEST(rb_obj_is_kind_of(range, rb_cArithSeq))) {
+ return (int)Qfalse;
+ }
else {
VALUE x;
b = rb_check_funcall(range, id_beg, 0, 0);
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 4660891e10..0d0fa94de3 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -2244,6 +2244,7 @@ class TestArray < Test::Unit::TestCase
def test_aref
assert_raise(ArgumentError) { [][0, 0, 0] }
+ assert_raise(TypeError) { [][(1..10).step(2)] }
end
def test_fetch