From: Steve Hancock Date: Wed, 7 Jul 2021 13:22:44 +0000 (-0700) Subject: Fix problem caused by side comment after pointer X-Git-Tag: 20210625.02~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=96f2ebb6d4c9d6aceb8d69d8f069792791ec824c;p=perltidy.git Fix problem caused by side comment after pointer --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 0c224083..a96375ad 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -3729,6 +3729,13 @@ EOM next; } + # A bare word preceded by -> is an identifier; mark as 'w'. + # Fixes c037. + if ( $last_nonblank_token eq '->' ) { + $type = 'w'; + next; + } + # a bare word immediately followed by :: is not a keyword; # use $tok_kw when testing for keywords to avoid a mistake my $tok_kw = $tok; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index c34d60a2..8faed76c 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,33 @@ =over 4 +=item B + +The following test script + + is( + $one + ->#sc# + package + , + "bar" + , + "Got package" + ) + ; + +Caused the following error message: + + 4: package + ^ + found package where operator expected + +The problem was caused by a side comment between the pointer '->' and +the word 'package'. This caused package to be misparsed as a keyword, +causing the error. + +This is fixed in this update, case c037. + =item B Perltidy was correctly distinguishing between '$#' and '$ #' but not between