summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class.c3
-rw-r--r--test/ruby/test_keyword.rb12
-rw-r--r--version.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/class.c b/class.c
index 43530c9461..5c54b0c7d4 100644
--- a/class.c
+++ b/class.c
@@ -1841,6 +1841,9 @@ rb_extract_keywords(VALUE *orighash)
}
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];
}
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index ad0bf63492..f10412e6cd 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -629,4 +629,16 @@ class TestKeywordArguments < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index f20673b426..cd57f4918f 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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