зеркало из https://github.com/github/ruby.git
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1ec457c2ff
Коммит
91afce9afa
|
@ -1,3 +1,10 @@
|
|||
Sat Dec 14 17:39:00 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* configure.in (rubylibprefix): replace exec_prefix as well as
|
||||
|
|
|
@ -401,6 +401,16 @@ class TestKeywordArguments < Test::Unit::TestCase
|
|||
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{
|
||||
|
|
|
@ -1109,7 +1109,7 @@ vm_callee_setup_arg_complex(rb_thread_t *th, rb_call_info_t *ci, const rb_iseq_t
|
|||
|
||||
/* 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 *th, const rb_iseq_t * iseq,
|
|||
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 *th, const rb_iseq_t * iseq,
|
|||
*/
|
||||
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 *th, const rb_iseq_t * iseq,
|
|||
|
||||
/* 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++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче