From: Steve Hancock Date: Tue, 27 Oct 2020 23:29:30 +0000 (-0700) Subject: fixed problem parsing extruded signature X-Git-Tag: 20201001.03~32 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9b454f686578630832448a6618215c8fee5fc1a5;p=perltidy.git fixed problem parsing extruded signature --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 63e5900d..2c621290 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -6356,13 +6356,28 @@ sub scan_identifier_do { if ( $in_prototype_or_signature && $tok =~ /^[\),=#]/ ) { - # see mangle4.in for test case + # We might be in an extrusion of + # sub foo2 ( $first, $, $third ) { + # looking at a line starting with a comma, like + # $ + # , + # ... in this case the comma ends the signature variable '$' which + # will have been previously marked type 't' rather than 'i'. + if ( $i == $i_begin ) { + $identifier = ""; + $type = ""; + } + # at a # we have to mark as type 't' because more may follow, # otherwise, in a signature we can let '$' be an identifier - # here for better formatting. - $type = 'i'; - if ( $id_scan_state eq '$' && $tok eq '#') { $type = 't' } - $i = $i_save; + # here for better formatting. see 'mangle4.in' for test case + else { + $type = 'i'; + if ( $id_scan_state eq '$' && $tok eq '#' ) { + $type = 't'; + } + $i = $i_save; + } $id_scan_state = ''; last; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index bd88d804..bb5bce51 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,34 @@ =over 4 +=item b + +A parsing error was encountered in a test parsing the following extruded +signature: + + sub foo2 + ( + $ + first + , + $ + , + $ + third + ) + { + return + "first=$first, third=$third" + ; + } + +The second '$' combined with the ',' on the next line to form a punctuation variable. +This was fixed 20 Oct 2020. The file parses correctly now, with formatted output + + sub foo2 ( $first, $, $third ) { + return "first=$first, third=$third"; + } + =item b Several instances of incorrect array indexing were found in testing and fixed.