aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-13 16:18:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-13 16:18:45 +0000
commit163f9abe4f2ba66ef433b327e0ceb2edb249e3ae (patch)
tree6dbc317886a3e1125fa0ebfdfca2eea5c4af54a8 /vm.c
parent2deb6e8ee2db4e0ce02b6e161508633dcc44ded1 (diff)
downloadruby-163f9abe4f2ba66ef433b327e0ceb2edb249e3ae.tar.gz
vm_insnhelper.c: relax arity check
* vm.c (invoke_block_from_c): add splattable argument. * vm.c (vm_invoke_proc): disallow to splat when directly invoked. * vm_insnhelper.c (vm_callee_setup_arg_complex, vm_callee_setup_arg): relax arity check of yielded lambda. [ruby-core:61340] [Bug #9605] * test/ruby/test_yield.rb (TestRubyYieldGen#emu_bind_params): no longer raise ArgumentError when splatting to lambda. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/vm.c b/vm.c
index d9ac0284f8..2e26e8c953 100644
--- a/vm.c
+++ b/vm.c
@@ -716,7 +716,7 @@ static inline VALUE
invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
VALUE self, int argc, const VALUE *argv,
const rb_block_t *blockptr, const NODE *cref,
- VALUE defined_class)
+ VALUE defined_class, int splattable)
{
if (SPECIAL_CONST_P(block->iseq))
return Qnil;
@@ -734,7 +734,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
}
opt_pc = vm_yield_setup_args(th, iseq, argc, cfp->sp, blockptr,
- type == VM_FRAME_MAGIC_LAMBDA);
+ (type == VM_FRAME_MAGIC_LAMBDA) ? splattable+1 : 0);
vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH,
self, defined_class,
@@ -772,7 +772,7 @@ vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cre
{
const rb_block_t *blockptr = check_block(th);
return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, 0, cref,
- blockptr->klass);
+ blockptr->klass, 1);
}
static inline VALUE
@@ -780,7 +780,7 @@ vm_yield(rb_thread_t *th, int argc, const VALUE *argv)
{
const rb_block_t *blockptr = check_block(th);
return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, 0, 0,
- blockptr->klass);
+ blockptr->klass, 1);
}
static inline VALUE
@@ -788,7 +788,7 @@ vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block
{
const rb_block_t *blockptr = check_block(th);
return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, blockargptr, 0,
- blockptr->klass);
+ blockptr->klass, 1);
}
static VALUE
@@ -805,7 +805,7 @@ vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class
th->safe_level = proc->safe_level;
}
val = invoke_block_from_c(th, &proc->block, self, argc, argv, blockptr, 0,
- defined_class);
+ defined_class, 0);
}
TH_POP_TAG();