]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed problem parsing extruded signature
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 27 Oct 2020 23:29:30 +0000 (16:29 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 27 Oct 2020 23:29:30 +0000 (16:29 -0700)
lib/Perl/Tidy/Tokenizer.pm
local-docs/BugLog.pod

index 63e5900dcaebe4b0114ade5c3bb53c37d4ad72f2..2c6212907b90bea20d2a31fa04f30a3e68d381ff 100644 (file)
@@ -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;
                 }
index bd88d80443b4f4de700dd939aea2e75aa7c2f83d..bb5bce516cf3ddc9122e11541f5baa506b6bbb53 100644 (file)
@@ -2,6 +2,34 @@
 
 =over 4
 
+=item b<Fixed problem parsing extruded signature>
+
+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<Fixed several uses of undefined variables found in testing>
 
 Several instances of incorrect array indexing were found in testing and fixed.