From 2f832a41ed2f1eaa14ee74a0f661d6220cabb916 Mon Sep 17 00:00:00 2001 From: Flavio Soibelmann Glock Date: Wed, 21 Jan 2026 13:01:36 +0100 Subject: [PATCH 1/2] Add tests for non-local next from inside nested subs --- src/test/resources/unit/control_flow.t | 107 +++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/src/test/resources/unit/control_flow.t b/src/test/resources/unit/control_flow.t index f5fdcf1f3..05f3ec3eb 100644 --- a/src/test/resources/unit/control_flow.t +++ b/src/test/resources/unit/control_flow.t @@ -48,6 +48,113 @@ subtest 'local next - labeled' => sub { 'labeled next continues correct loop'); }; +subtest 'non-local next - unlabeled (inside sub)' => sub { + my @output; + my $do_next = sub { + my ($i, $j) = @_; + push @output, "in-sub-$i,$j"; + next; + push @output, "after-next-$i,$j"; + }; + + for my $i (1..2) { + for my $j (1..3) { + push @output, "before-$i,$j"; + if ($j == 2) { + $do_next->($i, $j); + } + push @output, "after-$i,$j"; + } + } + + is_deeply( + \@output, + [ + 'before-1,1', 'after-1,1', + 'before-1,2', 'in-sub-1,2', + 'before-1,3', 'after-1,3', + 'before-2,1', 'after-2,1', + 'before-2,2', 'in-sub-2,2', + 'before-2,3', 'after-2,3', + ], + 'next from inside sub continues the innermost loop', + ); +}; + +subtest 'non-local next - labeled (inside sub)' => sub { + my @output; + my $do_next_outer = sub { + my ($i, $j) = @_; + push @output, "in-sub-$i,$j"; + next OUTER; + push @output, "after-next-$i,$j"; + }; + + OUTER: for my $i (1..3) { + for my $j (1..3) { + push @output, "before-$i,$j"; + if ($j == 2) { + $do_next_outer->($i, $j); + } + push @output, "after-$i,$j"; + } + } + + is_deeply( + \@output, + [ + 'before-1,1', 'after-1,1', + 'before-1,2', 'in-sub-1,2', + 'before-2,1', 'after-2,1', + 'before-2,2', 'in-sub-2,2', + 'before-3,1', 'after-3,1', + 'before-3,2', 'in-sub-3,2', + ], + 'labeled next from inside sub continues the correct labeled loop', + ); +}; + +subtest 'non-local next - labeled (A->B->C calls)' => sub { + my @output; + my $C = sub { + my ($i, $j) = @_; + push @output, "in-C-$i,$j"; + next OUTER; + push @output, "after-next-$i,$j"; + }; + my $B = sub { + my ($i, $j) = @_; + $C->($i, $j); + }; + my $A = sub { + my ($i, $j) = @_; + $B->($i, $j); + }; + + OUTER: for my $i (1..3) { + for my $j (1..3) { + push @output, "before-$i,$j"; + if ($j == 2) { + $A->($i, $j); + } + push @output, "after-$i,$j"; + } + } + + is_deeply( + \@output, + [ + 'before-1,1', 'after-1,1', + 'before-1,2', 'in-C-1,2', + 'before-2,1', 'after-2,1', + 'before-2,2', 'in-C-2,2', + 'before-3,1', 'after-3,1', + 'before-3,2', 'in-C-3,2', + ], + 'labeled next propagates through A->B->C and continues the correct labeled loop', + ); +}; + subtest 'local redo - unlabeled' => sub { my @output; my $count = 0; From 36a8955be28367d49ff2693df2cb0c04135563b0 Mon Sep 17 00:00:00 2001 From: Flavio Soibelmann Glock Date: Wed, 21 Jan 2026 13:04:35 +0100 Subject: [PATCH 2/2] Ignore local .err/.out and .windsurf artifacts --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f27269e23..644095202 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,6 @@ test_yaml_0yml # Ignore some Perl modules we are testing Image-ExifTool-* +/.err +/.out +/.windsurf/