summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2005-05-07 12:57:06 +0000
committerDave Mitchell <davem@fdisolutions.com>2005-05-07 12:57:06 +0000
commita034e688aeb372632feafc428b392a22393dec55 (patch)
tree00edd69325fa45e86f3a3a37b5ef01820d454559 /op.c
parent5203fbcae61b42c66ba138a48162ecc0880db2c9 (diff)
downloadperl-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.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/op.c b/op.c
index ef8dfcae2a..f3f7b6a744 100644
--- a/op.c
+++ b/op.c
@@ -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);
}