]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix problem caused by side comment after pointer
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 7 Jul 2021 13:22:44 +0000 (06:22 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 7 Jul 2021 13:22:44 +0000 (06:22 -0700)
lib/Perl/Tidy/Tokenizer.pm
local-docs/BugLog.pod

index 0c22408300dd4826983feef59f43e3357931e71d..a96375ad806f8e0fb05d169d353a5e77381b2e62 100644 (file)
@@ -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;
index c34d60a2f3bdac4ab8c92e8dbf0282c51a58ee6e..8faed76ceeda4a70d3e1a07876cfea8ebf3ab59c 100644 (file)
@@ -2,6 +2,33 @@
 
 =over 4
 
+=item B<Fix problem caused by side comment after pointer>
+
+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<Fix error parsing '%#' and similar combinations>
 
 Perltidy was correctly distinguishing between '$#' and '$ #' but not between