mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (iseq_set_arguments), insnhelper.ci
(vm_callee_setup_arg, vm_yield_setup_args): fix block parameter problems. [ruby-dev:31437], [ruby-dev:31440] * bootstraptest/test_block.rb: add a test of [ruby-dev:31440]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4657257b75
commit
fc466622fd
4 changed files with 24 additions and 7 deletions
|
@ -1,3 +1,11 @@
|
|||
Fri Aug 17 01:25:23 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* compile.c (iseq_set_arguments), insnhelper.ci
|
||||
(vm_callee_setup_arg, vm_yield_setup_args): fix
|
||||
block parameter problems. [ruby-dev:31437], [ruby-dev:31440]
|
||||
|
||||
* bootstraptest/test_block.rb: add a test of [ruby-dev:31440].
|
||||
|
||||
Fri Aug 17 01:24:12 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* iseq.c (ruby_iseq_disasm): fix to show arg_simple value.
|
||||
|
|
|
@ -417,3 +417,10 @@ assert_equal '0', %q{
|
|||
end
|
||||
m {|*,v| v}.inspect
|
||||
}, '[ruby-dev:31437]'
|
||||
assert_equal '[0]', %q{
|
||||
def m
|
||||
yield [0]
|
||||
end
|
||||
m{|v, &b| v}.inspect
|
||||
}, '[ruby-dev:31440]'
|
||||
|
||||
|
|
12
compile.c
12
compile.c
|
@ -881,7 +881,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
|
|||
/* set arg_size: size of arguments */
|
||||
if (iseq->arg_block != -1) {
|
||||
iseq->arg_size = iseq->arg_block + 1;
|
||||
}
|
||||
}
|
||||
else if (iseq->arg_post_len) {
|
||||
iseq->arg_size = iseq->arg_post_start + iseq->arg_post_len;
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
|
|||
else if (iseq->arg_opts) {
|
||||
iseq->arg_size = iseq->argc + iseq->arg_opts - 1;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
iseq->arg_size = iseq->argc;
|
||||
}
|
||||
}
|
||||
|
@ -901,9 +901,11 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
|
|||
}
|
||||
|
||||
if (iseq->type == ISEQ_TYPE_BLOCK) {
|
||||
if (iseq->argc == 1 && iseq->arg_simple == 1 && last_comma == 0) {
|
||||
/* {|a|} */
|
||||
iseq->arg_simple = 2;
|
||||
if (iseq->arg_opts == 0 && iseq->arg_post_len == 0 && iseq->arg_rest == -1) {
|
||||
if (iseq->argc == 1 && last_comma == 0) {
|
||||
/* {|a|} */
|
||||
iseq->arg_simple = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
|
|||
const int m = iseq->argc;
|
||||
const int orig_argc = argc;
|
||||
|
||||
if (iseq->arg_simple) {
|
||||
if (iseq->arg_simple == 1) {
|
||||
/* simple check */
|
||||
if (argc != m) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
|
||||
|
@ -675,7 +675,7 @@ vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
|
|||
* => {|a|} => a = [1, 2]
|
||||
* => {|a, b|} => a, b = [1, 2]
|
||||
*/
|
||||
if (iseq->arg_simple != 2 && m > 0 && argc == 1 && TYPE(argv[0]) == T_ARRAY) {
|
||||
if (iseq->arg_simple != 2 && (m + iseq->arg_post_len) > 0 && argc == 1 && TYPE(argv[0]) == T_ARRAY) {
|
||||
VALUE ary = argv[0];
|
||||
th->mark_stack_len = argc = RARRAY_LEN(ary);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue