From 107586f1fdffa4a1ba28a225481802df136f4596 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 15 Sep 2021 18:51:57 -0700 Subject: [PATCH] Fix unusual parsing error b1207 --- dev-bin/run_convergence_tests.pl.data | 11 ++++++++++ lib/Perl/Tidy/Tokenizer.pm | 3 ++- local-docs/BugLog.pod | 30 ++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index a871aee9..4af2d966 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7372,6 +7372,17 @@ if ( --stack-opening-hash-brace --weld-nested-containers +==> b1207.in <== +#OK: kkkkkbZZZZZZZZbxbiiiiiiii; + print $comment x $verbose; + +#ERR: kkkkkbZZZZZZZZbwZZZZZZZZ; + print $comment x$verbose; + + +==> b1207.par <== +--nowant-right-space='x' + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index ad1982d6..8ad5f09a 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -5393,8 +5393,9 @@ sub operator_expected { # Exception to weird parsing rules for 'x(' ... see case b1205: # In something like 'print $vv x(...' the x is an operator; + # Likewise in 'print $vv x$ww' the x is an operatory (case b1207) # otherwise x follows the weird parsing rules. - elsif ( $tok eq 'x' && $next_type eq '(' ) { + elsif ( $tok eq 'x' && $next_type =~ /^[\(\$\@\%]$/ ) { $op_expected = OPERATOR; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 4e28fb1d..20e9de85 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,13 +2,37 @@ =over 4 +=item B + +Testing with random parameters produced another instability caused by misparsing +an 'x' operator after a possible file handle. This is very similar to b1205, but +involves a sigil immediately following a times operator. + +To illustrate some cases, consider: + + sub x {print "arg is $_[0]\n"} + my $num = 3; + my @list=(1,2,3); + my %hash=(1,2,3,4); + open (my $fh, ">", "junk.txt"); + print $fh x$num; # prints a GLOB $num times to STDOUT + print $fh x9; # prints 'x9' to file 'junk.txt' + print $fh x@list; # prints a GLOB 3 times to STDOUT + print $fh x%hash; # prints a GLOB 2 times to STDOUT + +Note in particular the different treatment of the first two print statements. + +This update fixes case b1207. + +15 Sep 2021. + =item B Testing with random parameters produced an instability due welding with a very short line length and large value of -ci. This is similar to issues b1197-b1204 and fixed with a similar method. -14 Sep 2021. +14 Sep 2021, 9704cd7. =item B @@ -30,7 +54,7 @@ To illustrate, consider what these statements do: This update fixes case b1205. -13 Sep 2021. +13 Sep 2021, cfa2515. =item B @@ -52,7 +76,7 @@ parameter. This update fixes issues b1197 b1198 b1199 b1200 b1201 b1202 b1203 b1204 -12 Sep 2021. +12 Sep 2021, 0ac771e. =item B -- 2.39.5