ruby-changes:66312
From: nagachika <ko1@a...>
Date: Sat, 29 May 2021 14:05:06 +0900 (JST)
Subject: [ruby-changes:66312] 20bf397f7c (ruby_3_0): merge revision(s) fd8991f797c145615820b4c76e6b7ac5a71339ea: [Backport #17889]
https://git.ruby-lang.org/ruby.git/commit/?id=20bf397f7c From 20bf397f7cebd8156d76941dd54659cf9b8c8fe7 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 29 May 2021 14:04:25 +0900 Subject: 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(-) --- enumerator.c | 7 ++++++- test/ruby/test_lazy_enumerator.rb | 4 ++++ version.h | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/enumerator.c b/enumerator.c index b4a7cb5..90d2ec4 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 https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2678 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 3f5a055..2116d0e 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -682,4 +682,8 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_lazy_enumerator.rb#L682 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 21e0ab9..381a953 100644 --- a/version.h +++ b/version.h @@ -12,7 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12 # 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/