1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) r46342: [Backport #9954]

* 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/branches/ruby_2_1@46619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2014-06-29 18:22:39 +00:00
parent bdab29b10a
commit 370e83b789
4 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Mon Jun 30 03:15:59 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]
Mon Jun 30 03:07:22 2014 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (gets, readline): read lines without LF properly.

View file

@ -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{

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-06-30"
#define RUBY_PATCHLEVEL 156
#define RUBY_PATCHLEVEL 157
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 6

1
vm.c
View file

@ -2339,6 +2339,7 @@ m_core_hash_merge_kwd(int argc, VALUE *argv, VALUE recv)
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;
}