From 12bfdfe0eee8171a34b408d7a809c9d9afaaa876 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 26 Feb 2021 07:57:00 -0800 Subject: [PATCH] Update rule for spacing paren after constant function --- lib/Perl/Tidy/Formatter.pm | 3 ++- local-docs/BugLog.pod | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 1b179eb6..1c10b85a 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2156,7 +2156,8 @@ sub set_whitespace_flags { # 'w' and 'i' checks for something like: # myfun( &myfun( ->myfun( # ----------------------------------------------------- - elsif (( $last_type =~ /^[wUG]$/ ) + # Patch: added 'C' to prevent blinker, case b934, i.e. 'pi()' + elsif (( $last_type =~ /^[wCUG]$/ ) || ( $last_type =~ /^[wi]$/ && $last_token =~ /^(\&|->)/ ) ) { $ws = WS_NO unless ($rOpts_space_function_paren); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 4e3ab857..9a9f2570 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,31 @@ =over 4 +=item B + +Random testing produced an unstable state for the following snippet (case b934) + + sub pi(); + if ( + $t > + pi( ) + ) + +when run with these parameters: + + --continuation-indentation=6 + --maximum-line-length=17 + --paren-vertical-tightness-closing=2 + +The formatting was stable without the first line, which declares 'pi' to be +a constant sub. The problem was fixed by updating a regex to treat the spacing +of a paren following a sub the same for the two token types, 'U' or 'C' +(constant function). + +This fixes case b934. + +26 Feb 2021. + =item B This is a small change to the update of 13 Feb 2021, f79a4f1. Random testing -- 2.39.5