ruby-changes:46021
From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 00:39:44 +0900 (JST)
Subject: [ruby-changes:46021] usa:r58092 (ruby_2_2): merge revision(s) 57360: [Backport #12884]
usa 2017-03-26 00:39:40 +0900 (Sun, 26 Mar 2017) New Revision: 58092 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58092 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_2/ Modified files: branches/ruby_2_2/class.c branches/ruby_2_2/test/ruby/test_keyword.rb branches/ruby_2_2/version.h Index: ruby_2_2/class.c =================================================================== --- ruby_2_2/class.c (revision 58091) +++ ruby_2_2/class.c (revision 58092) @@ -1914,6 +1914,9 @@ rb_extract_keywords(VALUE *orighash) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/class.c#L1914 } 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_2/test/ruby/test_keyword.rb =================================================================== --- ruby_2_2/test/ruby/test_keyword.rb (revision 58091) +++ ruby_2_2/test/ruby/test_keyword.rb (revision 58092) @@ -603,4 +603,16 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_keyword.rb#L603 assert_equal({x: 1, y: 2, **h}, obj.foo) } 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_2/version.h =================================================================== --- ruby_2_2/version.h (revision 58091) +++ ruby_2_2/version.h (revision 58092) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.7" #define RUBY_RELEASE_DATE "2017-03-26" -#define RUBY_PATCHLEVEL 424 +#define RUBY_PATCHLEVEL 425 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r57360 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/