[前][次][番号順一覧][スレッド一覧]

ruby-changes:32760

From: naruse <ko1@a...>
Date: Wed, 5 Feb 2014 20:29:46 +0900 (JST)
Subject: [ruby-changes:32760] naruse:r44839 (ruby_2_1): merge revision(s) 44512: [Backport #9340]

naruse	2014-02-05 20:29:40 +0900 (Wed, 05 Feb 2014)

  New Revision: 44839

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44839

  Log:
    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.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/array.c
    branches/ruby_2_1/test/ruby/test_array.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/array.c
===================================================================
--- ruby_2_1/array.c	(revision 44838)
+++ ruby_2_1/array.c	(revision 44839)
@@ -3904,7 +3904,9 @@ ary_add_hash(VALUE hash, VALUE ary) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/array.c#L3904
 
     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;
 }
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 44838)
+++ ruby_2_1/ChangeLog	(revision 44839)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Wed Feb  5 17:55:28 2014  Aman Gupta <ruby@t...>
+
+	* 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.
+
 Wed Feb  5 11:48:42 2014  Charlie Somerville  <charliesome@r...>
 
 	* struct.c (rb_struct_set): return assigned value from setter method
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 44838)
+++ ruby_2_1/version.h	(revision 44839)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.1"
 #define RUBY_RELEASE_DATE "2014-02-05"
-#define RUBY_PATCHLEVEL 17
+#define RUBY_PATCHLEVEL 18
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_1/test/ruby/test_array.rb
===================================================================
--- ruby_2_1/test/ruby/test_array.rb	(revision 44838)
+++ ruby_2_1/test/ruby/test_array.rb	(revision 44839)
@@ -1524,6 +1524,11 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_array.rb#L1524
     assert(a.none?(&:frozen?))
     assert_equal(%w(a), b)
     assert(b.none?(&:frozen?))
+
+    bug9340 = "[ruby-core:59457]"
+    ary = [bug9340, bug9340.dup, bug9340.dup]
+    assert_equal 1, ary.uniq.size
+    assert_same bug9340, ary.uniq[0]
   end
 
   def test_uniq_with_block

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r44512


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]