summaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-12 14:46:46 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-12 14:46:46 +0000
commit98ee4d64f070a484bc9159010bb0fc727f297f7e (patch)
tree5b0556449748a13d6085048487dec4c6d94d64d2 /vm_insnhelper.c
parentd333161cec851f0370df25d85f77631121a06123 (diff)
downloadruby-98ee4d64f070a484bc9159010bb0fc727f297f7e.tar.gz
ruby-98ee4d64f070a484bc9159010bb0fc727f297f7e.tar.xz
ruby-98ee4d64f070a484bc9159010bb0fc727f297f7e.zip
merges r23956 from trunk into ruby_1_9_1.
-- * vm_insnhelper.c (vm_yield_setup_block_args): restores the first arg where is overwritten at funcall. [ruby-core:24139] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index ffb36e9a0..6132bd0fa 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -761,7 +761,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;
- VALUE ary;
+ VALUE ary, arg0;
int opt_pc = 0;
th->mark_stack_len = argc;
@@ -771,15 +771,19 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
* => {|a|} => a = [1, 2]
* => {|a, b|} => a, b = [1, 2]
*/
+ arg0 = argv[0];
if (!(iseq->arg_simple & 0x02) && /* exclude {|a|} */
(m + iseq->arg_post_len) > 0 && /* this process is meaningful */
- argc == 1 && !NIL_P(ary = rb_check_array_type(argv[0]))) { /* rhs is only an array */
+ argc == 1 && !NIL_P(ary = rb_check_array_type(arg0))) { /* rhs is only an array */
th->mark_stack_len = argc = RARRAY_LEN(ary);
CHECK_STACK_OVERFLOW(th->cfp, argc);
MEMCPY(argv, RARRAY_PTR(ary), VALUE, argc);
}
+ else {
+ argv[0] = arg0;
+ }
for (i=argc; i<m; i++) {
argv[i] = Qnil;