aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--enumerator.c2
-rw-r--r--test/ruby/test_enumerator.rb7
2 files changed, 7 insertions, 2 deletions
diff --git a/enumerator.c b/enumerator.c
index a366b75232..24444cdc53 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -550,6 +550,8 @@ enumerator_each(int argc, VALUE *argv, VALUE obj)
args = rb_ary_new4(argc, argv);
}
e->args = args;
+ e->size = Qnil;
+ e->size_fn = 0;
}
if (!rb_block_given_p()) return obj;
return enumerator_block_call(obj, 0, obj);
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index a24ff00d96..0839c2c3dd 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -301,8 +301,11 @@ class TestEnumerator < Test::Unit::TestCase
yield
end
ary = []
- e = o.to_enum.each(ary)
- e.next
+ e = o.to_enum { 1 }
+ assert_equal(1, e.size)
+ e_arg = e.each(ary)
+ assert_equal(nil, e_arg.size)
+ e_arg.next
assert_equal([1], ary)
end