File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,9 @@ If the LABEL is omitted, the loop control statement
330330refers to the innermost enclosing loop. This may include dynamically
331331searching through your call-stack at run time to find the LABEL. Such
332332desperate behavior triggers a warning if you use the C<use warnings>
333- pragma or the B<-w> flag.
333+ pragma or the B<-w> flag. If more than one label with the same name
334+ occurs, any reference to that name refers to the one labelling the
335+ innermost enclosing loop.
334336
335337If the condition expression of a C<while> statement is based
336338on any of a group of iterative expression types then it gets
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ BEGIN {
3636 set_up_inc(qw( . ../lib) );
3737}
3838
39- plan( tests => 67 );
39+ plan( tests => 69 );
4040
4141my $ok ;
4242
@@ -922,6 +922,23 @@ TEST41: {
922922}
923923cmp_ok($ok ,' ==' ,1,' dynamically scoped' );
924924
925+ TEST42: { # GH #18369
926+ my $outer = 0;
927+ my $inner = 0;
928+ L:
929+ for my $i (0 .. 0) {
930+ $outer ++;
931+
932+ L:
933+ for my $j (0 .. 0) {
934+ $inner ++;
935+ redo L if $inner < 10;
936+ }
937+ }
938+
939+ is ($inner , 10, " redo label refers to innermost enclosing one" );
940+ is ($outer , 1, " redo label doesn't refer to outermost enclosing one" );
941+ }
925942
926943# [perl #27206] Memory leak in continue loop
927944# Ensure that the temporary object is freed each time round the loop,
You can’t perform that action at this time.
0 commit comments