]> git.donarmstrong.com Git - perltidy.git/blobdiff - lib/Perl/Tidy/LineSource.pm
New upstream version 20210717
[perltidy.git] / lib / Perl / Tidy / LineSource.pm
index d11144d9911be7ea31ce9808fe140cfc99a8f7ec..f4798ca9547b13110ac91fd36d16fc7a9467cd0d 100644 (file)
@@ -8,11 +8,49 @@
 package Perl::Tidy::LineSource;
 use strict;
 use warnings;
-our $VERSION = '20200110';
+our $VERSION = '20210717';
+
+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;
+    return if ( $AUTOLOAD =~ /\bDESTROY$/ );
+    my ( $pkg, $fname, $lno ) = caller();
+    my $my_package = __PACKAGE__;
+    print STDERR <<EOM;
+======================================================================
+Error detected in package '$my_package', version $VERSION
+Received unexpected AUTOLOAD call 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
+    exit 1;
+}
+
+sub DESTROY {
+
+    # required to avoid call to AUTOLOAD in some versions of perl
+}
 
 sub new {
 
-    my ( $class, $input_file, $rOpts, $rpending_logfile_message ) = @_;
+    my ( $class, @args ) = @_;
+
+    my %defaults = (
+        input_file               => undef,
+        rOpts                    => undef,
+        rpending_logfile_message => undef,
+    );
+
+    my %args = ( %defaults, @args );
+
+    my $input_file               = $args{input_file};
+    my $rOpts                    = $args{rOpts};
+    my $rpending_logfile_message = $args{rpending_logfile_message};
 
     my $input_line_ending;
     if ( $rOpts->{'preserve-line-endings'} ) {