]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix c151, bareword x (
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 7 Jul 2022 15:54:47 +0000 (08:54 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 7 Jul 2022 15:54:47 +0000 (08:54 -0700)
lib/Perl/Tidy/Tokenizer.pm

index 8a7490738acdb5bfd51eee16ad4b25a6b92894ec..7e3b3d1eb27e4836fbf6df5fbf06f181aec516aa 100644 (file)
@@ -3829,9 +3829,17 @@ EOM
             $next_tok = $rtokens->[ $i + 1 ];
             if ( $next_tok eq '(' ) {
 
+                # Patch for issue c151, where we are processing a snippet and
+                # have not seen that SPACE is a constant.  In this case 'x' is
+                # probably an operator. The only disadvantage with an incorrect
+                # guess is that the space after it may be incorrect. For example
+                #   $str .= SPACE x ( 16 - length($str) );
+                if ( $tok eq 'x' && $last_nonblank_type eq 'w' ) { $type = 'x' }
+
                 # Fix part 2 for git #63.  Leave type as 'w' to keep
                 # the type the same as if the -> were not separated
-                $type = 'U' unless ( $last_nonblank_type eq '->' );
+                elsif ( $last_nonblank_type ne '->' ) { $type = 'U' }
+
             }
 
             # underscore after file test operator is file handle