1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) fd8991f797: [Backport #17889]

Fix lazy enumerator with index size

	Fixes [Bug #17889]
	---
	 enumerator.c                      | 7 ++++++-
	 test/ruby/test_lazy_enumerator.rb | 4 ++++
	 2 files changed, 10 insertions(+), 1 deletion(-)
This commit is contained in:
nagachika 2021-05-29 14:04:25 +09:00
parent 9d63a8dd0b
commit 20bf397f7c
3 changed files with 11 additions and 2 deletions

View file

@ -2678,8 +2678,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,
};
/*

View file

@ -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

View file

@ -12,7 +12,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 2
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 89
#define RUBY_PATCHLEVEL 90
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 5