ruby-changes:32128
From: nobu <ko1@a...>
Date: Sat, 14 Dec 2013 17:39:23 +0900 (JST)
Subject: [ruby-changes:32128] nobu:r44207 (trunk): vm_insnhelper.c: post arguments as mandatory
nobu 2013-12-14 17:39:17 +0900 (Sat, 14 Dec 2013) New Revision: 44207 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44207 Log: vm_insnhelper.c: post arguments as mandatory * vm_insnhelper.c (vm_callee_setup_arg_complex): count post arguments as mandatory arguments. [ruby-core:57706] [Bug #8993] * vm_insnhelper.c (vm_yield_setup_block_args): ditto. Modified files: trunk/ChangeLog trunk/test/ruby/test_keyword.rb trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 44206) +++ ChangeLog (revision 44207) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Dec 14 17:39:00 2013 Nobuyoshi Nakada <nobu@r...> + + * vm_insnhelper.c (vm_callee_setup_arg_complex): count post + arguments as mandatory arguments. [ruby-core:57706] [Bug #8993] + + * vm_insnhelper.c (vm_yield_setup_block_args): ditto. + Sat Dec 14 16:26:46 2013 Nobuyoshi Nakada <nobu@r...> * configure.in (rubylibprefix): replace exec_prefix as well as Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 44206) +++ vm_insnhelper.c (revision 44207) @@ -1109,7 +1109,7 @@ vm_callee_setup_arg_complex(rb_thread_t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1109 /* keyword argument */ if (iseq->arg_keyword != -1) { - argc = vm_callee_setup_keyword_arg(iseq, argc, m, orig_argv, &keyword_hash); + argc = vm_callee_setup_keyword_arg(iseq, argc, min, orig_argv, &keyword_hash); } /* mandatory */ @@ -2164,6 +2164,7 @@ vm_yield_setup_block_args(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2164 int i; int argc = orig_argc; const int m = iseq->argc; + const int min = m + iseq->arg_post_len; VALUE ary, arg0; VALUE keyword_hash = Qnil; int opt_pc = 0; @@ -2177,7 +2178,7 @@ vm_yield_setup_block_args(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2178 */ arg0 = argv[0]; if (!(iseq->arg_simple & 0x02) && /* exclude {|a|} */ - ((m + iseq->arg_post_len) > 0 || /* positional arguments exist */ + (min > 0 || /* positional arguments exist */ iseq->arg_opts > 2 || /* multiple optional arguments exist */ iseq->arg_keyword != -1 || /* any keyword arguments */ 0) && @@ -2200,7 +2201,7 @@ vm_yield_setup_block_args(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2201 /* keyword argument */ if (iseq->arg_keyword != -1) { - argc = vm_callee_setup_keyword_arg(iseq, argc, m, argv, &keyword_hash); + argc = vm_callee_setup_keyword_arg(iseq, argc, min, argv, &keyword_hash); } for (i=argc; i<m; i++) { Index: test/ruby/test_keyword.rb =================================================================== --- test/ruby/test_keyword.rb (revision 44206) +++ test/ruby/test_keyword.rb (revision 44207) @@ -401,6 +401,16 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L401 assert_equal([{}, {:bar=>"x"}], a.new.foo({}, bar: "x")) end + def test_precedence_of_keyword_arguments_with_post_argument + bug8993 = '[ruby-core:57706] [Bug #8993]' + a = Class.new do + def foo(a, b, c=1, *d, e, f:2, **g) + [a, b, c, d, e, f, g] + end + end + assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993) + end + def test_gced_object_in_stack bug8964 = '[ruby-dev:47729] [Bug #8964]' assert_normal_exit %q{ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/