[前][次][番号順一覧][スレッド一覧]

ruby-changes:34538

From: nagachika <ko1@a...>
Date: Mon, 30 Jun 2014 03:22:50 +0900 (JST)
Subject: [ruby-changes:34538] nagachika:r46619 (ruby_2_1): merge revision(s) r46342: [Backport #9954]

nagachika	2014-06-30 03:22:39 +0900 (Mon, 30 Jun 2014)

  New Revision: 46619

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46619

  Log:
    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]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/test/ruby/test_keyword.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/vm.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 46618)
+++ ruby_2_1/ChangeLog	(revision 46619)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Jun 30 03:15:59 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* lib/net/ftp.rb (gets, readline): read lines without LF properly.
Index: ruby_2_1/vm.c
===================================================================
--- ruby_2_1/vm.c	(revision 46618)
+++ ruby_2_1/vm.c	(revision 46619)
@@ -2339,6 +2339,7 @@ m_core_hash_merge_kwd(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm.c#L2339
     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;
 }
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 46618)
+++ ruby_2_1/version.h	(revision 46619)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #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
Index: ruby_2_1/test/ruby/test_keyword.rb
===================================================================
--- ruby_2_1/test/ruby/test_keyword.rb	(revision 46618)
+++ ruby_2_1/test/ruby/test_keyword.rb	(revision 46619)
@@ -452,6 +452,17 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_keyword.rb#L452
     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{

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r46342


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]