From: Gurusamy Sarathy Date: Sun, 23 Jan 2000 08:17:30 +0000 (+0000) Subject: fix localization in while BLOCK when there is a continue BLOCK X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=872465582bf743a066e1240f2c3e941735674827;p=p5sagit%2Fp5-mst-13.2.git fix localization in while BLOCK when there is a continue BLOCK by introducing an explicit scope (c.f. change#4848) p4raw-link: @4848 on //depot/perl: 1ee987245c095afd177d3e2ca6255cec8dbb53ca p4raw-id: //depot/perl@4849 --- diff --git a/op.c b/op.c index cdb4b23..06b6a70 100644 --- a/op.c +++ b/op.c @@ -3753,6 +3753,9 @@ Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP *loop, I32 whileline, OP * if (!block) block = newOP(OP_NULL, 0); + else if (cont) { + block = scope(block); + } if (cont) next = LINKLIST(cont); diff --git a/pp_ctl.c b/pp_ctl.c index af31a1c..8e41646 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1959,11 +1959,12 @@ PP(pp_next) if (cxix < cxstack_ix) dounwind(cxix); - TOPBLOCK(cx); + cx = &cxstack[cxstack_ix]; { OP *nextop = cx->blk_loop.next_op; /* clean scope, but only if there's no continue block */ if (nextop == cUNOPx(cx->blk_loop.last_op)->op_first->op_next) { + TOPBLOCK(cx); oldsave = PL_scopestack[PL_scopestack_ix - 1]; LEAVE_SCOPE(oldsave); } diff --git a/t/cmd/while.t b/t/cmd/while.t index 515a7b6..46bbdea 100755 --- a/t/cmd/while.t +++ b/t/cmd/while.t @@ -1,8 +1,6 @@ #!./perl -# $RCSfile: while.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:15 $ - -print "1..17\n"; +print "1..19\n"; open (tmp,'>Cmd_while.tmp') || die "Can't create Cmd_while.tmp."; print tmp "tvi925\n"; @@ -141,3 +139,24 @@ print "ok $i\n"; print "ok ", $var-1, "\nok $i\n"; } } + +{ + local $l = 18; + { + local $l = 0 + } + continue { + print "ok $l\n" + } +} + +{ + local $l = 19; + my $x = 0; + while (!$x++) { + local $l = 0 + } + continue { + print "ok $l\n" + } +}