]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix case b1172, a failure to converge
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 11 Jul 2021 13:19:57 +0000 (06:19 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 11 Jul 2021 13:19:57 +0000 (06:19 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod
t/snippets/expect/wn7.def
t/snippets/expect/wn7.wn
t/snippets/packing_list.txt
t/snippets17.t
t/snippets18.t

index 44ac10ea5042a45f978c5b4bb6e94adf9250140f..fd0f4dab97cc71e90edf990343bdaad1a614fbf1 100644 (file)
@@ -6471,6 +6471,42 @@ my $xx =
 --paren-tightness=2
 --space-function-paren
 
+==> b1172.in <==
+# S1
+
+ok(
+    '[{"1":[5]}]' eq
+             encode_json[
+                         {
+                      1=>[
+                               5
+                      ]
+                         }
+             ]
+);
+
+# S2
+
+ok('[{"1":[5]}]' eq
+             encode_json[
+                       {1=>
+                               [
+                               5
+                               ]
+                       }
+             ]);
+
+
+
+==> b1172.par <==
+--noadd-whitespace
+--continuation-indentation=9
+--extended-continuation-indentation
+--ignore-old-breakpoints
+--indent-columns=9
+--line-up-parentheses
+--maximum-line-length=27
+
 ==> b120.in <==
 # Same as bug96
 # State 1
index ea9ea09c2f01b0f74f97621fd4a4eaf9e572a4d9..4e9958497ab57d9ebcade275e7b6ec5411caab77 100644 (file)
@@ -16868,6 +16868,15 @@ sub set_continuation_breaks {
     } ## end sub scan_list
 } ## end closure scan_list
 
+my %is_kwiZ;
+
+BEGIN {
+
+    # Added 'w' to fix b1172
+    my @q = qw(k w i Z);
+    @is_kwiZ{@q} = (1) x scalar(@q);
+}
+
 sub find_token_starting_list {
 
     # When testing to see if a block will fit on one line, some
@@ -16879,7 +16888,7 @@ sub find_token_starting_list {
     # This will be the return index
     my $i_opening_minus = $i_opening_paren;
 
-    return $i_opening_minus if ( $i_opening_minus <= 0 );
+    goto RETURN if ( $i_opening_minus <= 0 );
 
     my $im1 = $i_opening_paren - 1;
     my ( $iprev_nb, $type_prev_nb ) = ( $im1, $types_to_go[$im1] );
@@ -16907,7 +16916,12 @@ sub find_token_starting_list {
         }
         if ( $types_to_go[$i_opening_minus] eq 'b' ) { $i_opening_minus++ }
     }
-    elsif ( $type_prev_nb eq 'k' ) { $i_opening_minus = $iprev_nb }
+
+    # Handle non-parens
+    elsif ( $is_kwiZ{$type_prev_nb} ) { $i_opening_minus = $iprev_nb }
+
+  RETURN:
+
     return $i_opening_minus;
 }
 
index e6f0ab9d8d4a60b7c5ec96ec9783cad587bd5b01..ad52685135503da3b024e954950d1d2292079af0 100644 (file)
@@ -2,6 +2,22 @@
 
 =over 4
 
+=item B<Fix case b1172, a failure to converge>
+
+Random testing produced case b1172, a failure to converge with unusual parametrs.
+This update fixes this case. There are no other known cases of instability
+at the present time but testing continues.
+
+10 Jul 2021.
+
+=item B<Avoid line breaks before a slash in certain cases>
+
+This update prevents a line break before a '/' character which follows a bareword or possible indirect object.  The purpose is reduce the chance of introducing a syntax error in cases where perl is using spaces to distinguish between a division and the start of a pattern.
+
+This fixes case c039.
+
+10 Jul 2021
+
 =item B<Removed warning message if ending in code skipping section>
 
 In the previous version, a warning was produced if a 'code-skipping' opening comment
index d95b2033ac1734c39d36d0a47c0092b6d4481ea3..168e23bbb977ba0b14608aabfd980f027c3ee97a 100644 (file)
@@ -1,6 +1,8 @@
                     # do not weld paren to opening one-line non-paren container
                     $Self->_Add(
-                        $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+                        $SortOrderDisplay{
+                            $Field->GenerateFieldForSelectSQL()
+                        }
                     );
 
                     # this will not get welded with -wn
index d95b2033ac1734c39d36d0a47c0092b6d4481ea3..168e23bbb977ba0b14608aabfd980f027c3ee97a 100644 (file)
@@ -1,6 +1,8 @@
                     # do not weld paren to opening one-line non-paren container
                     $Self->_Add(
-                        $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+                        $SortOrderDisplay{
+                            $Field->GenerateFieldForSelectSQL()
+                        }
                     );
 
                     # this will not get welded with -wn
index 481c5fef11bd84a79a4a4edbc16ab512ef0958df..d44b8b459c7d19bda9d5a6b1e2f6176dbfcdc565 100644 (file)
 ../snippets24.t        rt136417.def
 ../snippets24.t        rt136417.rt136417
 ../snippets24.t        numbers.def
+../snippets24.t        code_skipping.def
 ../snippets3.t ce_wn1.ce_wn
 ../snippets3.t ce_wn1.def
 ../snippets3.t colin.colin
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets24.t        code_skipping.def
index ab2d0ba19400829d25cbdcbf68dbb8be3b3bb235..858a99f1cc5bca68e0e469be599290df0d4c83a9 100644 (file)
@@ -1033,7 +1033,9 @@ sub plugh () : Ugly('\(") : Bad;
             expect => <<'#19...........',
                     # do not weld paren to opening one-line non-paren container
                     $Self->_Add(
-                        $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+                        $SortOrderDisplay{
+                            $Field->GenerateFieldForSelectSQL()
+                        }
                     );
 
                     # this will not get welded with -wn
index 51249bbbff46e99fcf5254e71455ec5ed58ccb1f..8a33351ae87c91fee896d7bfc382a1b66d839e10 100644 (file)
@@ -291,7 +291,9 @@ my ( $a, $b, $c ) = @_;    # test -nsak="my for"
             expect => <<'#1...........',
                     # do not weld paren to opening one-line non-paren container
                     $Self->_Add(
-                        $SortOrderDisplay{ $Field->GenerateFieldForSelectSQL() }
+                        $SortOrderDisplay{
+                            $Field->GenerateFieldForSelectSQL()
+                        }
                     );
 
                     # this will not get welded with -wn