From: Steve Hancock Date: Sun, 11 Jul 2021 13:19:57 +0000 (-0700) Subject: Fix case b1172, a failure to converge X-Git-Tag: 20210717~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=47e7f9b8851eb202b0a6fcefbe18105b0e6a29fb;p=perltidy.git Fix case b1172, a failure to converge --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 44ac10ea..fd0f4dab 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -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 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index ea9ea09c..4e995849 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index e6f0ab9d..ad526851 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,22 @@ =over 4 +=item B + +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 + +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 In the previous version, a warning was produced if a 'code-skipping' opening comment diff --git a/t/snippets/expect/wn7.def b/t/snippets/expect/wn7.def index d95b2033..168e23bb 100644 --- a/t/snippets/expect/wn7.def +++ b/t/snippets/expect/wn7.def @@ -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 diff --git a/t/snippets/expect/wn7.wn b/t/snippets/expect/wn7.wn index d95b2033..168e23bb 100644 --- a/t/snippets/expect/wn7.wn +++ b/t/snippets/expect/wn7.wn @@ -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 diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index 481c5fef..d44b8b45 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -323,6 +323,7 @@ ../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 @@ -463,4 +464,3 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets24.t code_skipping.def diff --git a/t/snippets17.t b/t/snippets17.t index ab2d0ba1..858a99f1 100644 --- a/t/snippets17.t +++ b/t/snippets17.t @@ -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 diff --git a/t/snippets18.t b/t/snippets18.t index 51249bbb..8a33351a 100644 --- a/t/snippets18.t +++ b/t/snippets18.t @@ -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