summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-05-29 14:04:25 +0900
committernagachika <nagachika@ruby-lang.org>2021-05-29 14:04:25 +0900
commit20bf397f7cebd8156d76941dd54659cf9b8c8fe7 (patch)
tree458345732362cd95fefd2b12ce0d101f17fab6b1
parent9d63a8dd0beefa49796eb86ab688c2eb0cd89a20 (diff)
merge revision(s) fd8991f797c145615820b4c76e6b7ac5a71339ea: [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(-)
-rw-r--r--enumerator.c7
-rw-r--r--test/ruby/test_lazy_enumerator.rb4
-rw-r--r--version.h2
3 files changed, 11 insertions, 2 deletions
diff --git a/enumerator.c b/enumerator.c
index b4a7cb588e..90d2ec433c 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -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,
};
/*
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
diff --git a/version.h b/version.h
index 21e0ab9215..381a953c2d 100644
--- a/version.h
+++ b/version.h
@@ -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