diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2005-05-07 12:57:06 +0000 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2005-05-07 12:57:06 +0000 |
commit | a034e688aeb372632feafc428b392a22393dec55 (patch) | |
tree | 00edd69325fa45e86f3a3a37b5ef01820d454559 /op.c | |
parent | 5203fbcae61b42c66ba138a48162ecc0880db2c9 (diff) | |
download | perl-a034e688aeb372632feafc428b392a22393dec55.tar.gz |
while (my $x ...) { ...; redo } shouldn't undef $x.
In the presence of 'my' in the conditional of a while(), until(),
or for(;;) loop, add an extra scope to the body so that redo
doesn't undef the lexical
p4raw-id: //depot/perl@24412
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -3799,7 +3799,8 @@ Perl_newLOOPOP(pTHX_ I32 flags, I32 debuggable, OP *expr, OP *block) } OP * -Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP *loop, I32 whileline, OP *expr, OP *block, OP *cont) +Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP *loop, I32 +whileline, OP *expr, OP *block, OP *cont, I32 has_my) { dVAR; OP *redo; @@ -3836,7 +3837,7 @@ Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP *loop, I32 whileline, OP * if (!block) block = newOP(OP_NULL, 0); - else if (cont) { + else if (cont || has_my) { block = scope(block); } @@ -3989,7 +3990,7 @@ Perl_newFOROP(pTHX_ I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *blo Renew(loop, 1, LOOP); #endif loop->op_targ = padoff; - wop = newWHILEOP(flags, 1, loop, forline, newOP(OP_ITER, 0), block, cont); + wop = newWHILEOP(flags, 1, loop, forline, newOP(OP_ITER, 0), block, cont, 0); PL_copline = forline; return newSTATEOP(0, label, wop); } |