mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (setup_args), vm.c (invoke_block_from_c),
vm_insnhelper.c (caller_setup_args): fix of r30241. lambda block shoud check argument number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0316582ebc
commit
cd3f980ea2
6 changed files with 14 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
Sat Dec 18 16:02:27 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compile.c (setup_args), vm.c (invoke_block_from_c),
|
||||
vm_insnhelper.c (caller_setup_args): fix of r30241. lambda block
|
||||
shoud check argument number.
|
||||
|
||||
Sat Dec 18 14:42:29 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* load.c: parenthesize macro arguments.
|
||||
|
|
|
@ -2899,6 +2899,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag, VALUE *b
|
|||
if (block && nd_type(argn->nd_body) == NODE_LAMBDA) {
|
||||
NODE *lambda = argn->nd_body;
|
||||
*block = NEW_CHILD_ISEQVAL(lambda->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(lambda));
|
||||
*flag |= VM_CALL_BLOCK_LAMBDA_BIT;
|
||||
}
|
||||
else {
|
||||
COMPILE(arg_block, "block", argn->nd_body);
|
||||
|
|
|
@ -29,6 +29,7 @@ __END__
|
|||
a = 0
|
||||
2.times(&->(_){ a += 1 })
|
||||
assert_equal(a, 2)
|
||||
assert_raise(ArgumentError) {1.times(&->(){ a += 1 })}
|
||||
end
|
||||
|
||||
def test_call_rest_args
|
||||
|
|
5
vm.c
5
vm.c
|
@ -531,7 +531,10 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
|
|||
const rb_control_frame_t *cfp;
|
||||
rb_control_frame_t *ncfp;
|
||||
int i, opt_pc, arg_size = iseq->arg_size;
|
||||
int type = block_proc_is_lambda(block->proc) ?
|
||||
int type =
|
||||
block->proc == Qtrue ? VM_FRAME_MAGIC_LAMBDA :
|
||||
block->proc == Qfalse ? VM_FRAME_MAGIC_BLOCK :
|
||||
block_proc_is_lambda(block->proc) ?
|
||||
VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK;
|
||||
|
||||
rb_vm_set_finish_env(th);
|
||||
|
|
|
@ -550,6 +550,7 @@ typedef struct {
|
|||
#define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
|
||||
#define VM_CALL_SUPER_BIT (0x01 << 7)
|
||||
#define VM_CALL_OPT_SEND_BIT (0x01 << 8)
|
||||
#define VM_CALL_BLOCK_LAMBDA_BIT (0x01 << 9)
|
||||
|
||||
enum vm_special_object_type {
|
||||
VM_SPECIAL_OBJECT_VMCORE = 1,
|
||||
|
|
|
@ -265,7 +265,7 @@ caller_setup_args(const rb_thread_t *th, rb_control_frame_t *cfp, VALUE flag,
|
|||
else if (blockiseq) {
|
||||
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp);
|
||||
blockptr->iseq = blockiseq;
|
||||
blockptr->proc = 0;
|
||||
blockptr->proc = (flag & VM_CALL_BLOCK_LAMBDA_BIT) ? Qtrue : Qfalse;
|
||||
*block = blockptr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue