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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
556e3da421
commit
13dffd8a2a
3
class.c
3
class.c
@ -1841,6 +1841,9 @@ rb_extract_keywords(VALUE *orighash)
|
|||||||
}
|
}
|
||||||
st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash);
|
st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash);
|
||||||
*orighash = parthash[1];
|
*orighash = parthash[1];
|
||||||
|
if (parthash[1] && RBASIC_CLASS(hash) != rb_cHash) {
|
||||||
|
RBASIC_SET_CLASS(parthash[1], RBASIC_CLASS(hash));
|
||||||
|
}
|
||||||
return parthash[0];
|
return parthash[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,4 +629,16 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||||||
klass.new(d: 4)
|
klass.new(d: 4)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user