summaryrefslogtreecommitdiff
path: root/t/op/loopctl.t
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 /t/op/loopctl.t
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 't/op/loopctl.t')
-rw-r--r--t/op/loopctl.t27
1 files changed, 26 insertions, 1 deletions
diff --git a/t/op/loopctl.t b/t/op/loopctl.t
index bc326c7b1a..11fb7c8ef7 100644
--- a/t/op/loopctl.t
+++ b/t/op/loopctl.t
@@ -31,7 +31,7 @@
#
# -- .robin. <robin@kitsite.com> 2001-03-13
-print "1..43\n";
+print "1..46\n";
my $ok;
@@ -967,3 +967,28 @@ print ($ok ? "ok 41\n" : "not ok 41\n");
}
+# ensure that redo doesn't clear a lexical delcared in the condition
+
+{
+ my $i = 1;
+ while (my $x = $i) {
+ $i++;
+ redo if $i == 2;
+ print $x == 1 ? "" : "not ", "ok 44 - while/redo lexical life\n";
+ last;
+ }
+ $i = 1;
+ until (! (my $x = $i)) {
+ $i++;
+ redo if $i == 2;
+ print $x == 1 ? "" : "not ", "ok 45 - until/redo lexical life\n";
+ last;
+ }
+ for ($i = 1; my $x = $i; ) {
+ $i++;
+ redo if $i == 2;
+ print $x == 1 ? "" : "not ", "ok 46 - for/redo lexical life\n";
+ last;
+ }
+
+}