]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed rt#131288
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 30 Dec 2019 00:02:14 +0000 (16:02 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 30 Dec 2019 00:02:14 +0000 (16:02 -0800)
CHANGES.md
lib/Perl/Tidy/Tokenizer.pm
t/snippets/expect/rt131288.def [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets/rt131288.in [new file with mode: 0644]
t/snippets16.t

index fb92cf5f2d8b73c2bf468e88983c69cded5ab84c..0f8d4d7fa134b629e299f9d53948c7b630fc9e9a 100644 (file)
@@ -2,6 +2,8 @@
 
 ## 2019 12 03.01
 
+    - Fixed issue RT#131288: parse error for un-prototyped constant function
+      followed by ternary.
 
 ## 2019 12 03
 
index 77b773236b68fdf1ddd520e11f9322cc7fbc4753..edc07aa9a2406cc49173e0acfe70cf563b6b6434 100644 (file)
@@ -2055,8 +2055,17 @@ sub prepare_for_a_new_file {
             {
                 $is_pattern = 0;
             }
+
+           # patch for RT#131288, user constant function without prototype
+           # last type is 'U' followed by ?. 
+            elsif (   $last_nonblank_type =~ /^[FUY]$/ ) {
+                $is_pattern = 0;
+           }
             elsif ( $expecting == UNKNOWN ) {
 
+               # FIXME: Can a bare ? still be a pattern delimiter in modern
+               # versions of Perl? Need to research this and decide what
+               # to do.
                 my $msg;
                 ( $is_pattern, $msg ) =
                   guess_if_pattern_or_conditional( $i, $rtokens, $rtoken_map,
diff --git a/t/snippets/expect/rt131288.def b/t/snippets/expect/rt131288.def
new file mode 100644 (file)
index 0000000..089bbb0
--- /dev/null
@@ -0,0 +1,3 @@
+sub OptArgs2::STYLE_FULL { 3 }
+$style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
+  'usage: ' . $usage . "\n";
index 25f505b9be36f01fee318e7865561b5092256490..5f4afdc0c726b2c2dde717efc74bfc5892649837 100644 (file)
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
+../snippets16.t        rt131288.def
diff --git a/t/snippets/rt131288.in b/t/snippets/rt131288.in
new file mode 100644 (file)
index 0000000..01fcf3c
--- /dev/null
@@ -0,0 +1,2 @@
+sub OptArgs2::STYLE_FULL { 3 }
+$style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage', 'usage: ' . $usage . "\n";
index ed36de83e409bbb04c35cecfb0bc302fd90cbcf9..3377c69a0c219812964cfb8c9ba38ad6b60f15a1 100644 (file)
@@ -16,6 +16,7 @@
 #13 rt131115.rt131115
 #14 ndsm1.def
 #15 ndsm1.ndsm
+#16 rt131288.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -126,6 +127,11 @@ sub a {
         $uniq{$par} = 1;
     }
 }
+----------
+
+        'rt131288' => <<'----------',
+sub OptArgs2::STYLE_FULL { 3 }
+$style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage', 'usage: ' . $usage . "\n";
 ----------
 
         'spp' => <<'----------',
@@ -339,6 +345,16 @@ sub Numerically { $a <=> $b };    # trapped semicolon
 __;
 #15...........
         },
+
+        'rt131288.def' => {
+            source => "rt131288",
+            params => "def",
+            expect => <<'#16...........',
+sub OptArgs2::STYLE_FULL { 3 }
+$style == OptArgs2::STYLE_FULL ? 'FullUsage' : 'NormalUsage',
+  'usage: ' . $usage . "\n";
+#16...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};