From 71770637fff39cb6028e3e9f6028013de2d1a2d4 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 6 Jun 2024 07:18:11 -0700 Subject: [PATCH] fix b1475 --- dev-bin/run_convergence_tests.pl.data | 17 +++++++++++++++++ dev-bin/run_convergence_tests.pl.expect | 8 ++++++++ lib/Perl/Tidy/Formatter.pm | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 27c455ce..59db65ca 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -12149,6 +12149,23 @@ my @global_ops = ( --extended-continuation-indentation --brace-tightness=2 +==> b1475.in <== +run_sub ( + ->$blah{ say "ok 5" ; } ) ; + +run_sub ( ->$blah{ say "ok 5" ; } +) ; + + +==> b1475.par <== +--maximum-line-length=36 +--extended-continuation-indentation +--paren-vertical-tightness=2 +--extended-line-up-parentheses +--space-function-paren +--space-terminal-semicolon +--break-at-old-method-breakpoints + ==> b148.in <== # state 1 @yydgoto=( diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index f761d75a..63e0b9fc 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -8243,6 +8243,14 @@ my @global_ops = ( iparse( {Maxiter => 200, Eps => 1e-4,}, ifhref($opt) ) }; +==> b1475 <== +run_sub ( + ->$blah{ say "ok 5" ; } ) ; + +run_sub ( + ->$blah{ say "ok 5" ; } ) ; + + ==> b148 <== # state 1 @yydgoto=( diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 31ee35ba..db5d7259 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -15650,6 +15650,12 @@ sub keep_old_line_breaks { # leading '->' use a value of 2 which causes a soft # break rather than a hard break if ( $type eq '->' ) { + + # ignore -bom after an opening token ( a syntax error, b1475 ) + my $Kp = $self->K_previous_nonblank($Kfirst); + next if ( !defined($Kp) ); + next if ( $is_opening_type{ $rLL->[$Kp]->[_TYPE_] } ); + $rbreak_before_Kfirst->{$Kfirst} = 2; } -- 2.39.5