ruby-changes:28153
From: nobu <ko1@a...>
Date: Tue, 9 Apr 2013 15:26:26 +0900 (JST)
Subject: [ruby-changes:28153] nobu:r40205 (trunk): compile.c: append keyword hash to splat
nobu 2013-04-09 15:26:15 +0900 (Tue, 09 Apr 2013) New Revision: 40205 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40205 Log: compile.c: append keyword hash to splat * compile.c (iseq_compile_each): append keyword hash to argument array to splat if needed. [ruby-core:54094] [Bug #8236] Modified files: trunk/ChangeLog trunk/compile.c trunk/test/ruby/test_keyword.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 40204) +++ ChangeLog (revision 40205) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Apr 9 15:26:12 2013 Nobuyoshi Nakada <nobu@r...> + + * compile.c (iseq_compile_each): append keyword hash to argument array + to splat if needed. [ruby-core:54094] [Bug #8236] + Tue Apr 9 10:02:39 2013 Nobuyoshi Nakada <nobu@r...> * lib/mkmf.rb (timestamp_file): gather timestamp files in one Index: compile.c =================================================================== --- compile.c (revision 40204) +++ compile.c (revision 40205) @@ -4499,6 +4499,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4499 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; + } } } } Index: test/ruby/test_keyword.rb =================================================================== --- test/ruby/test_keyword.rb (revision 40204) +++ test/ruby/test_keyword.rb (revision 40205) @@ -327,4 +327,25 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L327 assert_raise(ArgumentError, bug8139) {b.call(c: bug8139)} assert_raise(ArgumentError, bug8139) {b.call} 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/