summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--enumerator.c7
-rw-r--r--test/ruby/test_lazy_enumerator.rb4
2 files changed, 10 insertions, 1 deletions
diff --git a/enumerator.c b/enumerator.c
index 3ea4330802..fac83b4360 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -2700,8 +2700,13 @@ lazy_with_index_proc(VALUE proc_entry, struct MEMO* result, VALUE memos, long me
return result;
}
+static VALUE
+lazy_with_index_size(VALUE proc, VALUE receiver) {
+ return receiver;
+}
+
static const lazyenum_funcs lazy_with_index_funcs = {
- lazy_with_index_proc, 0,
+ lazy_with_index_proc, lazy_with_index_size,
};
/*
diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb
index 3f5a05555b..2116d0ee31 100644
--- a/test/ruby/test_lazy_enumerator.rb
+++ b/test/ruby/test_lazy_enumerator.rb
@@ -682,4 +682,8 @@ EOS
ary = (0..Float::INFINITY).lazy.with_index.take(2).to_a
assert_equal([[0, 0], [1, 1]], ary)
end
+
+ def test_with_index_size
+ assert_equal(3, Enumerator::Lazy.new([1, 2, 3], 3){|y, v| y << v}.with_index.size)
+ end
end