From f81224e90bab2a86136573d9d8984c2753f83e58 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 18 Oct 2024 20:38:09 -0700 Subject: [PATCH] add checks --- lib/Perl/Tidy/Formatter.pm | 42 ++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 12b85079..30a67c1c 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1261,6 +1261,9 @@ EOM sub check_token_array { my $self = shift; + #-------------- + # Check @{$rLL} + #-------------- # Check for errors in the array of tokens. This is only called # when the DEVEL_MODE flag is set, so this Fault will only occur # during code development. @@ -1294,7 +1297,9 @@ sub check_token_array { } } - # Check the array $rK_next_seqno_by_K->[$KK] + #--------------------------------- + # Check $rK_next_seqno_by_K->[$KK] + #--------------------------------- my $Klimit = @{$rLL} - 1; my $K_last_seqno; my $rK_next_seqno_by_K = $self->[_rK_next_seqno_by_K_]; @@ -1318,14 +1323,32 @@ EOM } # upon hitting an undef, the remaining values should also be undef - foreach my $KK ( $K_last_seqno + 1 .. $Klimit ) { - my $Ktest = $rK_next_seqno_by_K->[$KK]; - next if ( !defined($Ktest) ); - Fault(<[$KK]; + next if ( !defined($Ktest) ); + Fault(<[_rparent_of_seqno_]; + foreach my $seqno ( keys %{$rparent_of_seqno} ) { + + # parent sequence numbers must always be less + my $seqno_parent = $rparent_of_seqno->{$seqno}; + if ( $seqno_parent >= $seqno ) { + Fault(<= $high_stress_level ) + # removed. + # NOTE: The update for b1491 also fixes cases b1482-6 in a + # more general way, so this test can be deactivated. + if ( 0 + && !$rOpts_add_whitespace + && $level_words >= $high_stress_level ) { return; } -- 2.39.5