]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix non-fatal internal fault check c177
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 20 Jan 2023 01:03:38 +0000 (17:03 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 20 Jan 2023 01:03:38 +0000 (17:03 -0800)
add check to avoid creating an empty batch

lib/Perl/Tidy/Formatter.pm

index 7fe237ec8fab23fc077f2a899d7ba269ef792c7b..efca6d136462375a3754c021f45a863777f1fe52 100644 (file)
@@ -14971,13 +14971,16 @@ EOM
             # to add a blank.  The value of the flag is as follows:
             #   1 => hard break, flush the batch
             #   2 => soft break, set breakpoint and continue building the batch
-            if ( $self->[_rbreak_before_Kfirst_]->{$K_first_true} ) {
+            # added check on max_index_to_go for c177
+            if (   $max_index_to_go >= 0
+                && $self->[_rbreak_before_Kfirst_]->{$K_first_true} )
+            {
                 $index_start_one_line_block = undef;
                 if ( $self->[_rbreak_before_Kfirst_]->{$K_first_true} == 2 ) {
                     $self->set_forced_breakpoint($max_index_to_go);
                 }
                 else {
-                    $self->end_batch() if ( $max_index_to_go >= 0 );
+                    $self->end_batch();
                 }
             }
         }