From 96f2ebb6d4c9d6aceb8d69d8f069792791ec824c Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 7 Jul 2021 06:22:44 -0700 Subject: [PATCH] Fix problem caused by side comment after pointer --- lib/Perl/Tidy/Tokenizer.pm | 7 +++++++ local-docs/BugLog.pod | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) 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 -- 2.39.5