From: Steve Hancock Date: Mon, 9 Aug 2021 14:33:46 +0000 (-0700) Subject: Fix error parsing sub attributes without spaces, b1190 X-Git-Tag: 20210717.02~57 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7008bccec04e00712358bcb1f550bb2a8bb237b2;p=perltidy.git Fix error parsing sub attributes without spaces, b1190 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 2d53b292..f4fcad3a 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -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 diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index a5058483..6519c7bb 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -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/ diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index fe0bd9bc..a22ccf4b 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,17 @@ =over 4 +=item B + +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 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.