From: Steve Hancock Date: Sun, 11 Jul 2021 13:45:50 +0000 (-0700) Subject: Fix error parsing sub attributes with side comment X-Git-Tag: 20210717~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=80f2a3a95b23191469e7f58f8b0d9a9b520a43b4;p=perltidy.git Fix error parsing sub attributes with side comment --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index d62bb6fa..2e3daeb1 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -2293,9 +2293,11 @@ EOM # a pattern cannot follow certain keywords which take optional # arguments, like 'shift' and 'pop'. See also '?'. - if ( $last_nonblank_type eq 'k' + if ( + $last_nonblank_type eq 'k' && $is_keyword_rejecting_slash_as_pattern_delimiter{ - $last_nonblank_token} ) + $last_nonblank_token} + ) { $is_pattern = 0; } @@ -2534,9 +2536,11 @@ EOM # Patch for rt #126965 # a pattern cannot follow certain keywords which take optional # arguments, like 'shift' and 'pop'. See also '/'. - if ( $last_nonblank_type eq 'k' + if ( + $last_nonblank_type eq 'k' && $is_keyword_rejecting_question_as_pattern_delimiter{ - $last_nonblank_token} ) + $last_nonblank_token} + ) { $is_pattern = 0; } @@ -3603,8 +3607,11 @@ EOM print STDOUT "TOKENIZE:(@debug_list)\n"; }; - # turn off attribute list on first non-blank, non-bareword - if ( $pre_type ne 'w' ) { $in_attribute_list = 0 } + # Turn off attribute list on first non-blank, non-bareword. + # Added '#' to fix c038. + if ( $pre_type ne 'w' && $pre_type ne '#' ) { + $in_attribute_list = 0; + } ############################################################### # We have the next token, $tok. @@ -4713,7 +4720,9 @@ EOM # /^(\}|\{|BEGIN|END|CHECK|INIT|AUTOLOAD|DESTROY|UNITCHECK|continue|;|if|elsif|else|unless|while|until|for|foreach)$/ elsif ( $is_zero_continuation_block_type{ - $routput_block_type->[$i] } ) + $routput_block_type->[$i] + } + ) { $in_statement_continuation = 0; } @@ -4722,7 +4731,9 @@ EOM # /^(sort|grep|map|do|eval)$/ ) elsif ( $is_not_zero_continuation_block_type{ - $routput_block_type->[$i] } ) + $routput_block_type->[$i] + } + ) { } @@ -5082,10 +5093,12 @@ sub operator_expected { # // may follow perl functions which may be unary operators # see test file dor.t (defined or); - if ( $tok eq '/' + if ( + $tok eq '/' && $next_type eq '/' && $is_keyword_rejecting_slash_as_pattern_delimiter{ - $last_nonblank_token} ) + $last_nonblank_token} + ) { $op_expected = OPERATOR; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index ad526851..ca984434 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,17 @@ =over 4 +=item B + +Testing with side comments produced an error in the following snippet: + + sub plugh () :# + Ugly('\(") : Bad; + +This is fixed in this update, case c038. + +11 Jul 2021. + =item B Random testing produced case b1172, a failure to converge with unusual parametrs.