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

ruby-changes:46096

From: nagachika <ko1@a...>
Date: Tue, 28 Mar 2017 01:05:07 +0900 (JST)
Subject: [ruby-changes:46096] nagachika:r58167 (ruby_2_3): merge revision(s) 57360: [Backport #12884]

nagachika	2017-03-28 01:05:01 +0900 (Tue, 28 Mar 2017)

  New Revision: 58167

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58167

  Log:
    merge revision(s) 57360: [Backport #12884]
    
    class.c: non-keyword hash class
    
    * class.c (rb_extract_keywords): keep the class of non-keyword
      elements hash as the original.  [ruby-core:77813] [Bug #12884]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/class.c
    branches/ruby_2_3/test/ruby/test_keyword.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/test/ruby/test_keyword.rb
===================================================================
--- ruby_2_3/test/ruby/test_keyword.rb	(revision 58166)
+++ ruby_2_3/test/ruby/test_keyword.rb	(revision 58167)
@@ -624,4 +624,16 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_keyword.rb#L624
       klass.new(d: 4)
     end
   end
+
+  def test_non_keyword_hash_subclass
+    bug12884 = '[ruby-core:77813] [Bug #12884]'
+    klass = EnvUtil.labeled_class("Child", Hash)
+    obj = Object.new
+    def obj.t(params = klass.new, d: nil); params; end
+    x = klass.new
+    x["foo"] = "bar"
+    result = obj.t(x)
+    assert_equal(x, result)
+    assert_kind_of(klass, result, bug12884)
+  end
 end
Index: ruby_2_3/class.c
===================================================================
--- ruby_2_3/class.c	(revision 58166)
+++ ruby_2_3/class.c	(revision 58167)
@@ -1950,6 +1950,9 @@ rb_extract_keywords(VALUE *orighash) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/class.c#L1950
     }
     st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash);
     *orighash = parthash[1];
+    if (parthash[1] && RBASIC_CLASS(hash) != rb_cHash) {
+	RBASIC_SET_CLASS(parthash[1], RBASIC_CLASS(hash));
+    }
     return parthash[0];
 }
 
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 58166)
+++ ruby_2_3/version.h	(revision 58167)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.3"
 #define RUBY_RELEASE_DATE "2017-03-28"
-#define RUBY_PATCHLEVEL 276
+#define RUBY_PATCHLEVEL 277
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57360


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

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