From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Thu, 30 Mar 2023 23:41:42 +0000 (-0700)
Subject: fix c208, misparse of '$1x$2'
X-Git-Tag: 20230309.03~40
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=00b8f0baa3a6642f52fff932050ca73744350059;p=perltidy.git

fix c208, misparse of '$1x$2'

This was found in some obfuscated perl code.
---

diff --git a/dev-bin/run_tokenizer_tests.pl.data b/dev-bin/run_tokenizer_tests.pl.data
index 408ea2c4..0c6cb7b1 100644
--- a/dev-bin/run_tokenizer_tests.pl.data
+++ b/dev-bin/run_tokenizer_tests.pl.data
@@ -159,6 +159,9 @@ my $str = $$# the process ID
  . " xxx\n";
 print "str='$str'\n";
 
+==> c208.in <==
+$1x$2
+
 ==> git82.in <==
 say
 $
diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm
index 1a3a861f..0ca95c39 100644
--- a/lib/Perl/Tidy/Tokenizer.pm
+++ b/lib/Perl/Tidy/Tokenizer.pm
@@ -7893,9 +7893,11 @@ sub do_scan_package {
             }
         }
         elsif ( $tok =~ /^\w/ ) {    # alphanumeric ..
-            $saw_alpha     = 1;
-            $id_scan_state = $scan_state_COLON;    # now need ::
+            $saw_alpha = 1;
             $identifier .= $tok;
+
+            # now need :: except for special digit vars like '$1' (c208)
+            $id_scan_state = $tok =~ /^\d/ ? EMPTY_STRING : $scan_state_COLON;
         }
         elsif ( $tok eq '::' ) {
             $id_scan_state = $scan_state_ALPHA;