mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm.c: return the result hash
* vm.c (core_hash_merge_kwd): should return the result hash, which may be converted from and differ from the given argument. [ruby-core:62921] [Bug #9898] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fc3c52eb37
commit
140929d8ba
3 changed files with 18 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Jun 4 04:08:37 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm.c (core_hash_merge_kwd): should return the result hash, which
|
||||
may be converted from and differ from the given argument.
|
||||
[ruby-core:62921] [Bug #9898]
|
||||
|
||||
Tue Jun 3 23:32:34 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ruby.c (load_file_internal2): Extracted from load_file_internal.
|
||||
|
|
|
@ -452,6 +452,17 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||
assert_equal({a: 1}, h, bug9776)
|
||||
end
|
||||
|
||||
def test_splat_hash_conversion
|
||||
bug9898 = '[ruby-core:62921] [Bug #9898]'
|
||||
|
||||
o = Object.new
|
||||
def o.to_hash() { a: 1 } end
|
||||
assert_equal({a: 1}, m1(**o) {|x| break x}, bug9898)
|
||||
o2 = Object.new
|
||||
def o2.to_hash() { b: 2 } end
|
||||
assert_equal({a: 1, b: 2}, m1(**o, **o2) {|x| break x}, bug9898)
|
||||
end
|
||||
|
||||
def test_gced_object_in_stack
|
||||
bug8964 = '[ruby-dev:47729] [Bug #8964]'
|
||||
assert_normal_exit %q{
|
||||
|
|
1
vm.c
1
vm.c
|
@ -2357,6 +2357,7 @@ core_hash_merge_kwd(int argc, VALUE *argv)
|
|||
hash = argv[0];
|
||||
kw = argv[argc-1];
|
||||
kw = rb_convert_type(kw, T_HASH, "Hash", "to_hash");
|
||||
if (argc < 2) hash = kw;
|
||||
rb_hash_foreach(kw, argc < 2 ? kwcheck_i : kwmerge_i, hash);
|
||||
return hash;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue