From 8b36de8def9ef214df35241213af79a937dfd1dd Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 13 Jul 2021 09:10:56 -0700 Subject: [PATCH] Fix problem with side comment after pattern --- lib/Perl/Tidy/Tokenizer.pm | 11 +++++++---- local-docs/BugLog.pod | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 7dec8997..0ced2cf2 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -3767,9 +3767,9 @@ EOM if ( $last_nonblank_token eq '->' ) { scan_bare_identifier(); - # Patch for c043, part 4; use type 'w' after a '->' - # This is just a safety check on sub scan_bare_identifier, which - # should get this case correct. + # Patch for c043, part 4; use type 'w' after a '->'. + # This is just a safety check on sub scan_bare_identifier, + # which should get this case correct. $type = 'w'; next; } @@ -7792,7 +7792,10 @@ sub is_possible_numerator { } else { - if ( $next_nonblank_token =~ /^\s*$/ ) { + # Added '#' to fix issue c044 + if ( $next_nonblank_token =~ /^\s*$/ + || $next_nonblank_token eq '#' ) + { $is_pattern = 0; } else { diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index bfc33fe6..536903be 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,26 @@ =over 4 +=item B + +Testing with randomly placed side comments produced an error illustrated +with the following snippet: + + testit + /A (*THEN) X | B (*THEN) C/x#sc# + , + "Simple (*THEN) test" + ; + +If 'testit' is an unknown bareword then perltidy has to guess +if the '/' is a division or can start a pattern. In this case the side +comment caused a bad guess. This is case c044 and is fixed with this update. +There are no other known issues with side comments at the present time +but testing continues. + +13 Jul 2021. + + =item B This update fixes some incorrect tokenization produced by a side comment -- 2.39.5