ruby-changes:34370
From: nagachika <ko1@a...>
Date: Tue, 17 Jun 2014 00:59:26 +0900 (JST)
Subject: [ruby-changes:34370] nagachika:r46451 (ruby_2_1): merge revision(s) r45724: [Backport #9776]
nagachika 2014-06-17 00:59:16 +0900 (Tue, 17 Jun 2014) New Revision: 46451 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46451 Log: merge revision(s) r45724: [Backport #9776] * compile.c (compile_array_): make copy a first hash not to modify the argument itself. keyword splat should be non-destructive. [ruby-core:62161] [Bug #9776] Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/compile.c branches/ruby_2_1/test/ruby/test_keyword.rb branches/ruby_2_1/version.h Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 46450) +++ ruby_2_1/ChangeLog (revision 46451) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Tue Jun 17 00:45:44 2014 Nobuyoshi Nakada <nobu@r...> + + * compile.c (compile_array_): make copy a first hash not to modify + the argument itself. keyword splat should be non-destructive. + [ruby-core:62161] [Bug #9776] + Tue Jun 17 00:37:15 2014 Bugra Barin <bugrabarin@h...> * dln.c (dln_load): use wchar version to load a library in Index: ruby_2_1/compile.c =================================================================== --- ruby_2_1/compile.c (revision 46450) +++ ruby_2_1/compile.c (revision 46451) @@ -2479,6 +2479,7 @@ compile_array_(rb_iseq_t *iseq, LINK_ANC https://github.com/ruby/ruby/blob/trunk/ruby_2_1/compile.c#L2479 if (i > 0 || !first) ADD_INSN(ret, line, swap); COMPILE(ret, "keyword splat", kw); ADD_SEND(ret, line, ID2SYM(id_core_hash_merge_kwd), nhash); + if (nhash == INT2FIX(1)) ADD_SEND(ret, line, ID2SYM(rb_intern("dup")), INT2FIX(0)); } first = 0; break; Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 46450) +++ ruby_2_1/version.h (revision 46451) @@ -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-17" -#define RUBY_PATCHLEVEL 131 +#define RUBY_PATCHLEVEL 132 #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 46450) +++ ruby_2_1/test/ruby/test_keyword.rb (revision 46451) @@ -439,6 +439,19 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_keyword.rb#L439 assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993) end + def test_splat_keyword_nondestructive + bug9776 = '[ruby-core:62161] [Bug #9776]' + + h = {a: 1} + assert_equal({a:1, b:2}, {**h, b:2}) + assert_equal({a:1}, h, bug9776) + + pr = proc {|**opt| next opt} + assert_equal({a: 1}, pr.call(**h)) + assert_equal({a: 1, b: 2}, pr.call(**h, b: 2)) + assert_equal({a: 1}, h, bug9776) + 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:r45724 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/