]> git.donarmstrong.com Git - perltidy.git/commitdiff
add AUTOLOAD subs to better catch programming errors
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 7 Sep 2020 00:59:12 +0000 (17:59 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 7 Sep 2020 00:59:12 +0000 (17:59 -0700)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/HtmlWriter.pm
lib/Perl/Tidy/Tokenizer.pm
lib/Perl/Tidy/VerticalAligner.pm

index a7a71819a4569f5c4e288ef2514fee727dde53c9..7db691aa9ad9922f947c7f01b3abc6f3f5f53abc 100644 (file)
@@ -113,6 +113,25 @@ BEGIN {
     $VERSION = '20200907';
 }
 
+sub AUTOLOAD {
+
+    # Catch any undefined sub calls so that we are sure to get
+    # some diagnostic information.  This sub should never be called
+    # except for a programming error.
+    our $AUTOLOAD;
+    my ( $pkg, $fname, $lno ) = caller();
+    print STDERR <<EOM;
+======================================================================
+Unexpected call to Autoload looking for sub $AUTOLOAD
+Called from package: '$pkg'  
+Called from File '$fname'  at line '$lno'
+This error is probably due to a recent programming change
+======================================================================
+EOM
+    Die(
+        "Error exit due to unexpected Autoload call to '$AUTOLOAD'\n");
+}
+
 sub streamhandle {
 
     # given filename and mode (r or w), create an object which:
index 2fff8663c42fb8d034d537af21d501346829a3f4..a90370418bf3e71ef9f806a32e3a0ac92d70280b 100644 (file)
@@ -35,6 +35,24 @@ sub Exit {
     croak "unexpected return from Perl::Tidy::Exit";
 }
 
+sub AUTOLOAD {
+
+    # Catch any undefined sub calls so that we are sure to get
+    # some diagnostic information.  This sub should never be called
+    # except for a programming error.
+    our $AUTOLOAD;
+    my ( $pkg, $fname, $lno ) = caller();
+    print STDERR <<EOM;
+======================================================================
+Unexpected call to Autoload looking for sub $AUTOLOAD
+Called from package: '$pkg'  
+Called from File '$fname'  at line '$lno'
+This error is probably due to a recent programming change
+======================================================================
+EOM
+    Die("Error exit due to unexpected Autoload call to '$AUTOLOAD'\n");
+}
+
 BEGIN {
 
     # Codes for insertion and deletion of blanks
index 52665f2a513d8fa814572fd06e3a7ad42d6233c5..c175f7e061a650e228d569dbf1cbd66d41c5867a 100644 (file)
@@ -38,6 +38,25 @@ BEGIN {
     }
 }
 
+sub AUTOLOAD {
+
+    # Catch any undefined sub calls so that we are sure to get
+    # some diagnostic information.  This sub should never be called
+    # except for a programming error.
+    our $AUTOLOAD;
+    my ( $pkg, $fname, $lno ) = caller();
+    print STDERR <<EOM;
+======================================================================
+Unexpected call to Autoload looking for sub $AUTOLOAD
+Called from package: '$pkg'  
+Called from File '$fname'  at line '$lno'
+This error is probably due to a recent programming change
+======================================================================
+EOM
+    Perl::Tidy::Die(
+        "Error exit due to unexpected Autoload call to '$AUTOLOAD'\n");
+}
+
 sub new {
 
     my ( $class, @args ) = @_;
index 1089587ee611affb683d657d9896c3a14fec9045..0d803e67a3750146410ae85652b71c6a8debe5ed 100644 (file)
@@ -203,6 +203,25 @@ sub DESTROY {
     return;
 }
 
+sub AUTOLOAD {
+
+    # Catch any undefined sub calls so that we are sure to get
+    # some diagnostic information.  This sub should never be called
+    # except for a programming error.
+    our $AUTOLOAD;
+    my ( $pkg, $fname, $lno ) = caller();
+    print STDERR <<EOM;
+======================================================================
+Unexpected call to Autoload looking for sub $AUTOLOAD
+Called from package: '$pkg'  
+Called from File '$fname'  at line '$lno'
+This error is probably due to a recent programming change
+======================================================================
+EOM
+    Perl::Tidy::Die(
+        "Error exit due to unexpected Autoload call to '$AUTOLOAD'\n");
+}
+
 sub check_options {
 
     # Check Tokenizer parameters
index 36f574633cb6fb52bbe49037751e9aad9d8637bb..77d63abb91598ecd8706497b4c9b8d75e0444fdc 100644 (file)
@@ -29,6 +29,25 @@ use Perl::Tidy::VerticalAligner::Line;
 # It is essential that a final call to flush() be made. Otherwise some
 # final lines of text will be lost.
 
+sub AUTOLOAD {
+
+    # Catch any undefined sub calls so that we are sure to get
+    # some diagnostic information.  This sub should never be called
+    # except for a programming error.
+    our $AUTOLOAD;
+    my ( $pkg, $fname, $lno ) = caller();
+    print STDERR <<EOM;
+======================================================================
+Unexpected call to Autoload looking for sub $AUTOLOAD
+Called from package: '$pkg'  
+Called from File '$fname'  at line '$lno'
+This error is probably due to a recent programming change
+======================================================================
+EOM
+    Perl::Tidy::Die(
+        "Error exit due to unexpected Autoload call to '$AUTOLOAD'\n");
+}
+
 BEGIN {
 
     # Define the fixed indexes for variables in $self, which is an array