]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix rule for welding with barewords
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 30 Mar 2021 02:19:16 +0000 (19:19 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 30 Mar 2021 02:19:16 +0000 (19:19 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index f6f68bb1a3b0bc1a6dcdd9edff9444bc2a5427a5..b089659fd9d6db8e4d2de737231cb941210c36dc 100644 (file)
@@ -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;
index 3b9f68f111f641ca02118187fdc6bb010e1fb2f5..9fa3522b4861456da5d6032b0b79e5a813cf08f4 100644 (file)
@@ -2,6 +2,17 @@
 
 =over 4
 
+=item B<Fix rule for welding with barewords>
+
+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<Fix conflict between -wba='||' and -opr>
 
 Random testing produced a problem with convergence due to a conflict