]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix error parsing sub attributes without spaces, b1190
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 9 Aug 2021 14:33:46 +0000 (07:33 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 9 Aug 2021 14:33:46 +0000 (07:33 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Tokenizer.pm
local-docs/BugLog.pod

index 2d53b292f4dcac64a010f54d9bf6040f10a06c13..f4fcad3a569ac44d13cf5bccef4306364d5c6b1f 100644 (file)
@@ -7060,6 +7060,42 @@ if ($ON_EBCDIC)
 --notrim-qw
 --weld-nested-containers
 
+==> b1190.in <==
+# S1
+print
+  "not "
+  unless
+  ref+(
+    map{
+      sub:
+        lvalue{
+            "a";
+        }
+    }1
+  )[0]eq
+  "CODE";
+
+# S2
+print
+  "not "
+  unless
+  ref+(
+    map{
+        sub:lvalue
+        {
+            "a";
+        }
+    }1
+  )[0]eq
+  "CODE";
+
+
+==> b1190.par <==
+--noadd-whitespace
+--maximum-line-length=10
+--opening-anonymous-sub-brace-on-new-line
+--variable-maximum-line-length
+
 ==> b120.in <==
 # Same as bug96
 # State 1
index a50584835217302e01bb10bfbae5d8157a66d5ae..6519c7bbcb2161ca21fb236af8ca5c690e118599 100644 (file)
@@ -3794,13 +3794,14 @@ EOM
                 # Decide if 'sub :' can be the start of a sub attribute list.
                 # We will decide based on if the colon is followed by a
                 # bareword which is not a keyword.
+                # Changed inext+1 to inext to fixed case b1190.
                 my $sub_attribute_ok_here;
                 if (   $is_sub{$tok_kw}
                     && $expecting != OPERATOR
                     && $next_nonblank_token eq ':' )
                 {
                     my ( $nn_nonblank_token, $i_nn ) =
-                      find_next_nonblank_token( $i_next + 1,
+                      find_next_nonblank_token( $i_next,
                         $rtokens, $max_token_index );
                     $sub_attribute_ok_here =
                          $nn_nonblank_token =~ /^\w/
index fe0bd9bc07ae74e7f619323bb278a9012240b45e..a22ccf4b0be786154fef45623b222351005f5e25 100644 (file)
@@ -2,6 +2,17 @@
 
 =over 4
 
+=item B<Fix error parsing sub attributes without spaces, b1190>
+
+Testing with random parameters produced an instability which was caused
+by incorrect parsing of a sub attribute list without spaces, as in
+
+        sub:lvalue{"a"}
+
+This update fixes case b1190.
+
+9 Aug 2021.
+
 =item B<Fix rare loss of vertical alignment in welded containers, c053>
 
 This update corrects a rare loss of vertical alignment in welded containers.
@@ -105,7 +116,7 @@ And welding can still be done on all qw quotes unless the -notrim-qw flag is set
 
 This fixes case b1189.
 
-7 Aug 2021.
+7 Aug 2021, e9c25f2.
 
 =item B<Fix edge cases of formatting instability, b1187 b1188>.