From: Steve Hancock Date: Tue, 30 Mar 2021 02:19:16 +0000 (-0700) Subject: Fix rule for welding with barewords X-Git-Tag: 20210402~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d6770820655388b57429516239e20f18d6716834;p=perltidy.git Fix rule for welding with barewords --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f6f68bb1..b089659f 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7392,7 +7392,11 @@ EOM # DO-NOT-WELD RULE 6: Do not weld to a container which is followed on # the same line by an unknown bareword token. This can cause # blinkers (cases b626, b611). - if ( !$do_not_weld_rule ) { + # Patched for cases b1057 b1064: skip RULE 6 for a one-line weld. + # Note: Another, more general fix is to remove the check on line + # numbers and always do this. That was tested and works, and may be + # necessary in the future, but it could change some existing code. + if ( !$do_not_weld_rule && !$is_one_line_weld ) { my $Knext_io = $self->K_next_nonblank($Kinner_opening); next unless ( defined($Knext_io) ); my $iline_io_next = $rLL->[$Knext_io]->[_LINE_INDEX_]; @@ -7403,7 +7407,7 @@ EOM # such as 'Z' and 'Y': if ($type_io_next =~ /^[ZYw]$/) { if ( $type_io_next eq 'w' ) { my $Knext_io2 = $self->K_next_nonblank($Knext_io); - next unless ( defined($Knext_io) ); + next unless ( defined($Knext_io2) ); my $type_io_next2 = $rLL->[$Knext_io2]->[_TYPE_]; if ( !$type_ok_after_bareword{$type_io_next2} ) { $do_not_weld_rule = 6; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 3b9f68f1..9fa3522b 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,17 @@ =over 4 +=item B + +Random testing produced a case which was not converging due to a rule +which avoids welding when a bareword follows. The rule was modified to allow +an exception for an existing one-line weld. A non-fatal typo was also +discovered and fixed. + +This fixes cases b1057 b1064. + +29 Mar 2021. + =item B Random testing produced a problem with convergence due to a conflict