summaryrefslogtreecommitdiff
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
commit073598064efc483260ecb17bc66412ba7f9b8062 (patch)
tree5b0556449748a13d6085048487dec4c6d94d64d2 /vm_insnhelper.c
parent9331ca8fc28cec57f04dcbb1c70e4ff6494833dd (diff)
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: svn+ssh://ci.ruby-lang.org/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 ffb36e9a00..6132bd0fa0 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;