ruby-changes:45788
From: naruse <ko1@a...>
Date: Sun, 12 Mar 2017 02:17:29 +0900 (JST)
Subject: [ruby-changes:45788] naruse:r57861 (ruby_2_4): merge revision(s) 57360: [Backport #12884]
naruse 2017-03-12 02:17:23 +0900 (Sun, 12 Mar 2017) New Revision: 57861 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57861 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_4/ Modified files: branches/ruby_2_4/class.c branches/ruby_2_4/test/ruby/test_keyword.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 57860) +++ ruby_2_4/version.h (revision 57861) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.0" #define RUBY_RELEASE_DATE "2017-03-12" -#define RUBY_PATCHLEVEL 26 +#define RUBY_PATCHLEVEL 27 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/test/ruby/test_keyword.rb =================================================================== --- ruby_2_4/test/ruby/test_keyword.rb (revision 57860) +++ ruby_2_4/test/ruby/test_keyword.rb (revision 57861) @@ -629,4 +629,16 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_keyword.rb#L629 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_4/class.c =================================================================== --- ruby_2_4/class.c (revision 57860) +++ ruby_2_4/class.c (revision 57861) @@ -1841,6 +1841,9 @@ rb_extract_keywords(VALUE *orighash) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/class.c#L1841 } 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]; } Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r57360 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/