$tok_kw .= '::';
}
+ # 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.
+ 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,
+ $rtokens, $max_token_index );
+ $sub_attribute_ok_here =
+ $nn_nonblank_token =~ /^\w/
+ && $nn_nonblank_token !~ /^\d/
+ && !$is_keyword{$nn_nonblank_token};
+ }
+
# handle operator x (now we know it isn't $x=)
if ( $expecting == OPERATOR
&& substr( $tok, 0, 1 ) eq 'x'
elsif (
( $next_nonblank_token eq ':' )
&& ( $rtokens->[ $i_next + 1 ] ne ':' )
- && ( $i_next <= $max_token_index ) # colon on same line
+ && ( $i_next <= $max_token_index ) # colon on same line
+ && !$sub_attribute_ok_here # like 'sub : lvalue' ?
&& label_ok()
)
{
=over 4
+=item B<Fix token type of colon introducing anonomyous sub attribute list>
+
+In the following example
+
+ print "not " unless ref +(
+ map {
+ sub : lvalue { "a" }
+ } 1
+ )[0] eq "CODE";
+
+the colon after 'sub' was being marked as part of a label rather than the start
+of an attribute list. This does not cause an error, but the space before the
+':' is lost. This is fixed in this update.
+
+Note that something like 'sub :' can also be a label, so the tokenizer has to
+look ahead to decide what to do. For example, this 'sub :' is a label:
+
+ my $xx = 0;
+ sub : {
+ $xx++;
+ print "looping with label sub:, a=$xx\n";
+ if ( $xx < 10 ) { goto "sub" }
+ }
+
+In this case, the goto statement needs quotes around "sub" because it is a
+keyword.
+
+29 Jun 2021.
+
=item B<Minor adjustments to improve formatting stability>
Testing with random input parameters produced several new cases of formatting
28 Jun 2021.
-=item B<Remove limit on the value of -ci=n when -xci is set>
+=item B<Remove limit on -ci=n when -xci is set, see rt #136415>
This update undoes the update c16c5ee of 20 Feb 2021, in which the value
of -ci=n was limited to the value of -i=n when -xci was set. Recent