]> git.donarmstrong.com Git - perltidy.git/commitdiff
added error check for undefined opening token
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 13 Aug 2021 01:02:50 +0000 (18:02 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 13 Aug 2021 01:02:50 +0000 (18:02 -0700)
lib/Perl/Tidy/Formatter.pm

index eb969ae0d1643e824ce3fdb1a663103a3f1c374a..82b11194d5a86d83e4efc07f428a751ab756d56d 100644 (file)
@@ -4741,10 +4741,18 @@ EOM
                             my $opening_depth =
                               $rdepth_of_opening_seqno->[$seqno];
                             if ( !defined($opening_depth) ) {
-                                $opening_depth = $nesting_depth--;
+                                $opening_depth = $nesting_depth - 1;
                                 $opening_depth = 0 if ( $opening_depth < 0 );
                                 $rdepth_of_opening_seqno->[$seqno] =
                                   $opening_depth;
+
+                                # This is not fatal but should not happen. There
+                                # may be a problem in the tokenizer.
+                                if (DEVEL_MODE) {
+                                    Fault(<<EOM);
+No opening token seen for closing token = '$token' at seq=$seqno at depth=$opening_depth
+EOM
+                                }
                             }
                             $nesting_depth = $opening_depth;
                             $sign          = -1;