ruby-changes:52784
From: nagachika <ko1@a...>
Date: Thu, 11 Oct 2018 22:51:26 +0900 (JST)
Subject: [ruby-changes:52784] nagachika:r64996 (ruby_2_5): merge revision(s) 63030: [Backport #14639]
nagachika 2018-10-11 22:51:19 +0900 (Thu, 11 Oct 2018) New Revision: 64996 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64996 Log: merge revision(s) 63030: [Backport #14639] array.c: yield blockarg in collect * array.c (rb_ary_collect): yield in block argument semantics always to splat array elements to lambda, for the backward compatibility. [ruby-core:86362] [Bug #14639] Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/array.c branches/ruby_2_5/test/ruby/test_array.rb branches/ruby_2_5/version.h Index: ruby_2_5/array.c =================================================================== --- ruby_2_5/array.c (revision 64995) +++ ruby_2_5/array.c (revision 64996) @@ -2754,7 +2754,7 @@ rb_ary_collect(VALUE ary) https://github.com/ruby/ruby/blob/trunk/ruby_2_5/array.c#L2754 RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length); collect = rb_ary_new2(RARRAY_LEN(ary)); for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_ary_push(collect, rb_yield(RARRAY_AREF(ary, i))); + rb_ary_push(collect, rb_yield_force_blockarg(RARRAY_AREF(ary, i))); } return collect; } Index: ruby_2_5/test/ruby/test_array.rb =================================================================== --- ruby_2_5/test/ruby/test_array.rb (revision 64995) +++ ruby_2_5/test/ruby/test_array.rb (revision 64996) @@ -534,6 +534,8 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_array.rb#L534 # Enumerable#collect without block returns an Enumerator. #assert_equal([1, 2, 3], @cls[1, 2, 3].collect) assert_kind_of Enumerator, @cls[1, 2, 3].collect + + assert_equal([[1, 2, 3]], [[1, 2, 3]].collect(&->(a, b, c) {[a, b, c]})) end # also update map! Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 64995) +++ ruby_2_5/version.h (revision 64996) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.2" -#define RUBY_RELEASE_DATE "2018-10-09" -#define RUBY_PATCHLEVEL 96 +#define RUBY_RELEASE_DATE "2018-10-11" +#define RUBY_PATCHLEVEL 97 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 9 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 64995) +++ ruby_2_5 (revision 64996) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r63030 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/