From: Steve Hancock Date: Thu, 17 Sep 2020 01:20:16 +0000 (-0700) Subject: fixed problem parsing deprecated here-doc without target X-Git-Tag: 20201001~33 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7f41d62bc75d6a3e832ec043e77c17554635c3a8;p=perltidy.git fixed problem parsing deprecated here-doc without target --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index c02e834b..35d18d42 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -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"); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index bce44225..0223f16e 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -5,6 +5,23 @@ found with the help of automated random testing. =over +=item B + +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 The -> can now be vertically aligned if a space is placed before it with -wls='->'.