]> git.donarmstrong.com Git - perltidy.git/commitdiff
Check for side comment within package statement
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 4 Jul 2021 01:25:48 +0000 (18:25 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 4 Jul 2021 01:25:48 +0000 (18:25 -0700)
lib/Perl/Tidy/Tokenizer.pm
local-docs/BugLog.pod

index b0e3676d90d88a8660238518b73c6358bdc9013a..1be21abe2920b41c661e6cda7bbd1275ad36673a 100644 (file)
@@ -6601,7 +6601,8 @@ sub do_scan_package {
         # knows that the number is in a package statement.
         # Examples of valid primitive tokens that might follow are:
         #  1235  . ; { } v3  v
-        if ( $next_nonblank_token =~ /^([v\.\d;\{\}])|v\d|\d+$/ ) {
+        # FIX: added a '#' since a side comment may also follow
+        if ( $next_nonblank_token =~ /^([v\.\d;\{\}\#])|v\d|\d+$/ ) {
             $statement_type = $tok;
         }
         else {
index 41041242bc0c236eebf8630184fc5215f0a18688..567286e9664488bf8eb6abc7d7425a405c548588 100644 (file)
@@ -2,6 +2,17 @@
 
 =over 4
 
+=item B<Check for side comment within package statement>
+
+Testing with randomly placed side comments caused perltidy to produce an incorrect
+warning when a side comment is placed before the end of a package statement:
+
+    package double # side comment
+    ;
+
+This update fixes this.
+3 Jul 2021.
+
 =item B<Fix problem with -comma-arrow-breakpoint=n flag>
 
 Testing revealed a formatting irregularity which was caused when the flag