]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed problem parsing deprecated here-doc without target
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 17 Sep 2020 01:20:16 +0000 (18:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 17 Sep 2020 01:20:16 +0000 (18:20 -0700)
lib/Perl/Tidy/Tokenizer.pm
local-docs/BugLog.pod

index c02e834b4d632023938f161cc24f51779073b13c..35d18d42f2884dcba1d550b834ef2037052b711c 100644 (file)
@@ -2406,9 +2406,12 @@ sub prepare_for_a_new_file {
             scan_bare_identifier();
         },
         '<<' => sub {    # maybe a here-doc?
-            return
-              unless ( $i < $max_token_index )
-              ;          # here-doc not possible if end of line
+
+##      This check removed because it could be a deprecated here-doc with
+##      no specified target.  See example in log 16 Sep 2020.
+##            return
+##              unless ( $i < $max_token_index )
+##              ;          # here-doc not possible if end of line
 
             if ( $expecting != OPERATOR ) {
                 my ( $found_target, $here_doc_target, $here_quote_character,
@@ -2428,6 +2431,10 @@ sub prepare_for_a_new_file {
                         my $truncated = substr( $here_doc_target, 0, 80 );
                         complain("Long here-target: '$truncated' ...\n");
                     }
+                    elsif ( !$here_doc_target ) {
+                        warning(
+                            'Use of bare << to mean <<"" is deprecated\n');
+                    }
                     elsif ( $here_doc_target !~ /^[A-Z_]\w+$/ ) {
                         complain(
                             "Unconventional here-target: '$here_doc_target'\n");
index bce442258fcae0b97886c0a18c38c0b080fe1b58..0223f16e87408a38f84a78e439797c92136b0ba7 100644 (file)
@@ -5,6 +5,23 @@ found with the help of automated random testing.
 
 =over
 
+=item B<fix incorrect parsing of certain deprecated empty here-docs >
+
+The following snippet was being incorrecly parsed:
+
+ print <<
+ # Hello World 13!
+   ;
+ print "DONE\n";
+
+This is a deprecated here-doc without a specified target but currently still a
+valid program.  It would have been correctly parsed if the semicolon followed 
+the '<<' operator rather than the here-doc.  
+
+This was found in random testing and fixed 16 Sep 2020.  A warning message about
+deprecated here-doc targets was added.
+
 =item B<make the arrow a vertical alignment token, git #39>
 
 The -> can now be vertically aligned if a space is placed before it with -wls='->'.