From e7dda086170a5eaa037ddd5ebfcdc3aade15a26d Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 19 Jul 2024 13:08:11 -0700 Subject: [PATCH] Do not set Enumerator::Lazy#zip to use packed format Enumerator#zip yields a single array, not multiple arguments, so Enumerator::Lazy#zip should do the same. Fixes [#20623] --- enumerator.c | 1 - test/ruby/test_lazy_enumerator.rb | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/enumerator.c b/enumerator.c index b8ca6bddd2..8fa7bb8a36 100644 --- a/enumerator.c +++ b/enumerator.c @@ -2400,7 +2400,6 @@ lazy_zip_func(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_inde rb_ary_push(ary, v); } LAZY_MEMO_SET_VALUE(result, ary); - LAZY_MEMO_SET_PACKED(result); return result; } diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index 22127e903a..4dddbab50c 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -489,6 +489,10 @@ EOS assert_equal [1, 2, 3], enum.map { |x| x / 2 } end + def test_lazy_zip_map_yield_arity_bug_20623 + assert_equal([[1, 2]], [1].lazy.zip([2].lazy).map { |x| x }.force) + end + def test_lazy_to_enum lazy = [1, 2, 3].lazy def lazy.foo(*args)