ruby-changes:47399
From: nagachika <ko1@a...>
Date: Sat, 5 Aug 2017 12:25:00 +0900 (JST)
Subject: [ruby-changes:47399] nagachika:r59515 (ruby_2_4): merge revision(s) 59128: [Backport #13669]
nagachika 2017-08-05 12:24:54 +0900 (Sat, 05 Aug 2017) New Revision: 59515 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59515 Log: merge revision(s) 59128: [Backport #13669] Fix Enumerable#uniq with non single yield arguments * enum.c (uniq_func, uniq_iter): need packed value as the unique key. [ruby-core:81734] [Bug #13669] [Fix GH-1658] Author: Kenichi Kamiya <kachick1@g...> Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/enum.c branches/ruby_2_4/test/ruby/test_enum.rb branches/ruby_2_4/version.h Index: ruby_2_4/enum.c =================================================================== --- ruby_2_4/enum.c (revision 59514) +++ ruby_2_4/enum.c (revision 59515) @@ -3847,6 +3847,7 @@ enum_sum(int argc, VALUE* argv, VALUE ob https://github.com/ruby/ruby/blob/trunk/ruby_2_4/enum.c#L3847 static VALUE uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash)) { + ENUM_WANT_SVALUE(); rb_hash_add_new_element(hash, i, i); return Qnil; } @@ -3854,6 +3855,7 @@ uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, https://github.com/ruby/ruby/blob/trunk/ruby_2_4/enum.c#L3855 static VALUE uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash)) { + ENUM_WANT_SVALUE(); rb_hash_add_new_element(hash, rb_yield_values2(argc, argv), i); return Qnil; } Index: ruby_2_4/test/ruby/test_enum.rb =================================================================== --- ruby_2_4/test/ruby/test_enum.rb (revision 59514) +++ ruby_2_4/test/ruby/test_enum.rb (revision 59515) @@ -946,5 +946,6 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_enum.rb#L946 assert_equal([[1896, "Athens"], [1900, "Paris"], [1904, "Chicago"], [1908, "Rome"]], olympics.uniq{|k,v| v}) assert_equal([1, 2, 3, 4, 5, 10], (1..100).uniq{|x| (x**2) % 10 }.first(6)) + assert_equal([1, [1, 2]], Foo.new.to_enum.uniq) end end Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59514) +++ ruby_2_4/version.h (revision 59515) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-08-05" -#define RUBY_PATCHLEVEL 178 +#define RUBY_PATCHLEVEL 179 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59514) +++ ruby_2_4 (revision 59515) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59128 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/