Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90645fd

Browse files
committed
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 rubyGH-1658] Author: Kenichi Kamiya <[email protected]> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 5cf3632 commit 90645fd

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

enum.c

+2
Original file line numberDiff line numberDiff line change
@@ -3847,13 +3847,15 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
38473847
static VALUE
38483848
uniq_func(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
38493849
{
3850+
ENUM_WANT_SVALUE();
38503851
rb_hash_add_new_element(hash, i, i);
38513852
return Qnil;
38523853
}
38533854

38543855
static VALUE
38553856
uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
38563857
{
3858+
ENUM_WANT_SVALUE();
38573859
rb_hash_add_new_element(hash, rb_yield_values2(argc, argv), i);
38583860
return Qnil;
38593861
}

test/ruby/test_enum.rb

+1
Original file line numberDiff line numberDiff line change
@@ -946,5 +946,6 @@ def test_uniq
946946
assert_equal([[1896, "Athens"], [1900, "Paris"], [1904, "Chicago"], [1908, "Rome"]],
947947
olympics.uniq{|k,v| v})
948948
assert_equal([1, 2, 3, 4, 5, 10], (1..100).uniq{|x| (x**2) % 10 }.first(6))
949+
assert_equal([1, [1, 2]], Foo.new.to_enum.uniq)
949950
end
950951
end

version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.4.2"
22
#define RUBY_RELEASE_DATE "2017-08-05"
3-
#define RUBY_PATCHLEVEL 178
3+
#define RUBY_PATCHLEVEL 179
44

55
#define RUBY_RELEASE_YEAR 2017
66
#define RUBY_RELEASE_MONTH 8

0 commit comments

Comments
 (0)