fix localization in while BLOCK when there is a continue BLOCK
Gurusamy Sarathy [Sun, 23 Jan 2000 08:17:30 +0000 (08:17 +0000)]
by introducing an explicit scope (c.f. change#4848)

p4raw-link: @4848 on //depot/perl: 1ee987245c095afd177d3e2ca6255cec8dbb53ca

p4raw-id: //depot/perl@4849

op.c
pp_ctl.c
t/cmd/while.t

diff --git a/op.c b/op.c
index cdb4b23..06b6a70 100644 (file)
--- 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);
index af31a1c..8e41646 100644 (file)
--- 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);
        }
index 515a7b6..46bbdea 100755 (executable)
@@ -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"
+    }
+}