From a569165d3e6ef80fef747a33d8c47325e23c4430 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 19 Apr 2013 16:02:09 +0000 Subject: [PATCH] merge revision(s) 40205: [Backport #8236] * compile.c (iseq_compile_each): append keyword hash to argument array to splat if needed. [ruby-core:54094] [Bug #8236] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ compile.c | 5 +++++ test/ruby/test_keyword.rb | 21 +++++++++++++++++++++ version.h | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 50f173eef6..95bca34572 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Apr 20 00:41:10 2013 Nobuyoshi Nakada + + * compile.c (iseq_compile_each): append keyword hash to argument array + to splat if needed. [ruby-core:54094] [Bug #8236] + Sat Apr 20 00:31:57 2013 Kouhei Sutou * README.EXT.ja (Data_Wrap_Struct): Remove a description about diff --git a/compile.c b/compile.c index 2753cf80eb..34c9ae2b37 100644 --- a/compile.c +++ b/compile.c @@ -4485,6 +4485,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level)); } ADD_SEND(args, line, ID2SYM(id_core_hash_merge_ptr), INT2FIX(i * 2 + 1)); + if (liseq->arg_rest != -1) { + ADD_INSN1(args, line, newarray, INT2FIX(1)); + ADD_INSN (args, line, concatarray); + --argc; + } } } } diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 66f9cc8dbb..3107825573 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -290,4 +290,25 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(1, o.bug7942(), bug7942) assert_equal(42, o.bug7942(a: 42), bug7942) end + + def test_super_with_keyword + bug8236 = '[ruby-core:54094] [Bug #8236]' + base = Class.new do + def foo(*args) + args + end + end + a = Class.new(base) do + def foo(arg, bar: 'x') + super + end + end + b = Class.new(base) do + def foo(*args, bar: 'x') + super + end + end + assert_equal([42, {:bar=>"x"}], a.new.foo(42), bug8236) + assert_equal([42, {:bar=>"x"}], b.new.foo(42), bug8236) + end end diff --git a/version.h b/version.h index 138dd3a157..24cfa4e926 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-04-20" -#define RUBY_PATCHLEVEL 146 +#define RUBY_PATCHLEVEL 147 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 4