in the nature of a kludge; it doesn't fix the longstanding bug that
makes C<while (!$x++) { local $x = 7 } continue { print $x }> print "7"
instead of "1")
p4raw-id: //depot/perl@4848
dounwind(cxix);
TOPBLOCK(cx);
- oldsave = PL_scopestack[PL_scopestack_ix - 1];
- LEAVE_SCOPE(oldsave);
- return cx->blk_loop.next_op;
+ {
+ 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) {
+ oldsave = PL_scopestack[PL_scopestack_ix - 1];
+ LEAVE_SCOPE(oldsave);
+ }
+ return nextop;
+ }
}
PP(pp_redo)
# $RCSfile: while.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:15 $
-print "1..15\n";
+print "1..17\n";
open (tmp,'>Cmd_while.tmp') || die "Can't create Cmd_while.tmp.";
print tmp "tvi925\n";
$i++;
print "not " unless $` . $& . $' eq "abc";
print "ok $i\n";
+
+# check that scope cleanup happens right when there's a continue block
+{
+ my $var = 16;
+ while (my $i = ++$var) {
+ next if $i == 17;
+ last if $i > 17;
+ my $i = 0;
+ }
+ continue {
+ print "ok ", $var-1, "\nok $i\n";
+ }
+}