From 6aadd1051dbc24f38c77c8c728b0412dfe5a626c Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 30 Oct 2022 07:01:06 -0700 Subject: [PATCH] skip formatting and output verbatim on any brace errors --- lib/Perl/Tidy/Formatter.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 4abea51a..4b88f2eb 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5773,6 +5773,11 @@ sub finish_formatting { # The file has been tokenized and is ready to be formatted. # All of the relevant data is stored in $self, ready to go. + # Some of the code in sub break_lists is not robust enough to process code + # with arbitrary brace errors. The simplest fix is to just return the file + # verbatim if there are brace errors. This fixes issue c160. + $severe_error ||= get_saw_brace_error(); + # Check the maximum level. If it is extremely large we will give up and # output the file verbatim. Note that the actual maximum level is 1 # greater than the saved value, so we fix that here. -- 2.39.5