diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-05 11:29:40 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-05 11:29:40 +0000 |
commit | c0bdb2511d898cb875e75dc1e7f774112e5341f9 (patch) | |
tree | 69ca460e3c0029665ccec67beab5323399cdac64 /array.c | |
parent | bda2300c4d50a73bcda66f886c362e7f4da82da5 (diff) |
merge revision(s) 44512: [Backport #9340]
* array.c (ary_add_hash): Fix consistency issue between Array#uniq and
Array#uniq! [Bug #9340] [ruby-core:59457]
* test/ruby/test_array.rb (class TestArray): regression test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -3904,7 +3904,9 @@ ary_add_hash(VALUE hash, VALUE ary) for (i=0; i<RARRAY_LEN(ary); i++) { VALUE elt = RARRAY_AREF(ary, i); - rb_hash_aset(hash, elt, elt); + if (rb_hash_lookup2(hash, elt, Qundef) == Qundef) { + rb_hash_aset(hash, elt, elt); + } } return hash; } |