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
330
330
refers to the innermost enclosing loop. This may include dynamically
331
331
searching through your call-stack at run time to find the LABEL. Such
332
332
desperate 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.
334
336
335
337
If the condition expression of a C<while> statement is based
336
338
on 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 {
36
36
set_up_inc(qw( . ../lib) );
37
37
}
38
38
39
- plan( tests => 67 );
39
+ plan( tests => 69 );
40
40
41
41
my $ok ;
42
42
@@ -922,6 +922,23 @@ TEST41: {
922
922
}
923
923
cmp_ok($ok ,' ==' ,1,' dynamically scoped' );
924
924
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
+ }
925
942
926
943
# [perl #27206] Memory leak in continue loop
927
944
# Ensure that the temporary object is freed each time round the loop,
You can’t perform that action at this time.
0 commit comments