summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2013-08-22 22:57:01 +0100
committerZefram <zefram@fysh.org>2013-08-22 23:10:44 +0100
commitbf4588d0c394f60786161c36506f799e7007b077 (patch)
treecb3e392519e62a816c94268d5dfb0e55567e2d60 /dist
parentbd098b9ac583eefaa2df23e3b12fcae8a50321db (diff)
downloadperl-bf4588d0c394f60786161c36506f799e7007b077.tar.gz
detect Carp/Carp::Heavy version mismatch
[rt.cpan.org #79649] If an old Carp, requiring old-style Carp::Heavy that provides subroutines, gets a newer stub-style Carp::Heavy, due to @INC having changed, the resulting error messages were not awesome.
Diffstat (limited to 'dist')
-rw-r--r--dist/Carp/lib/Carp/Heavy.pm5
-rw-r--r--dist/Carp/t/heavy_mismatch.t8
2 files changed, 13 insertions, 0 deletions
diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm
index f0de26373a..f8c409e9f3 100644
--- a/dist/Carp/lib/Carp/Heavy.pm
+++ b/dist/Carp/lib/Carp/Heavy.pm
@@ -4,6 +4,11 @@ use Carp ();
our $VERSION = '1.32';
+my $cv = defined($Carp::VERSION) ? $Carp::VERSION : "undef";
+if($cv ne $VERSION) {
+ die "Version mismatch between Carp $cv ($INC{q(Carp.pm)}) and Carp::Heavy $VERSION ($INC{q(Carp/Heavy.pm)}). Did you alter \@INC after Carp was loaded?\n";
+}
+
1;
# Most of the machinery of Carp used to be here.
diff --git a/dist/Carp/t/heavy_mismatch.t b/dist/Carp/t/heavy_mismatch.t
new file mode 100644
index 0000000000..233bc5ace3
--- /dev/null
+++ b/dist/Carp/t/heavy_mismatch.t
@@ -0,0 +1,8 @@
+print "1..1\n";
+
+$INC{"Carp.pm"} = "<faked>";
+$Carp::VERSION = "0.90";
+eval { require Carp::Heavy; };
+print $@ =~ /\AVersion mismatch between Carp 0\.90 \(<faked>\) and Carp::Heavy [0-9._]+ \(.+\)\. Did you alter \@INC after Carp was loaded\?\n/ ? "" : "not ", "ok 1\n";
+
+1;