perl5db on miniperl
[p5sagit/p5-mst-13.2.git] / lib / Carp / Heavy.pm
index 4355584..a293b59 100644 (file)
@@ -55,7 +55,6 @@ sub  longmess_real {
 
 sub shortmess_real {
     # Icky backwards compatibility wrapper. :-(
-    my $call_pack = caller();
     local @CARP_NOT = caller();
     shortmess_heavy(@_);
 };
@@ -64,7 +63,12 @@ sub shortmess_real {
 
 # aliasing the whole glob rather than just the CV slot avoids 'redefined'
 # warnings, even in the presence of perl -W (as used by lib/warnings.t !)
+# However it has the potential to create infinite loops, if somehow Carp
+# is forcibly reloaded, but $INC{"Carp/Heavy.pm"} remains true.
+# Hence the extra hack of deleting the previous typeglob first.
 
+delete $Carp::{shortmess_jmp};
+delete $Carp::{longmess_jmp};
 *longmess_jmp  = *longmess_real;
 *shortmess_jmp = *shortmess_real;
 
@@ -220,7 +224,10 @@ sub ret_summary {
 
 
 sub short_error_loc {
-  my $cache;
+  # You have to create your (hash)ref out here, rather than defaulting it
+  # inside trusts *on a lexical*, as you want it to persist across calls.
+  # (You can default it on $_[2], but that gets messy)
+  my $cache = {};
   my $i = 1;
   my $lvl = $CarpLevel;
   {
@@ -270,7 +277,7 @@ sub str_len_trim {
 sub trusts {
     my $child = shift;
     my $parent = shift;
-    my $cache = shift || {};
+    my $cache = shift;
     my ($known, $partial) = get_status($cache, $child);
     # Figure out consequences until we have an answer
     while (@$partial and not exists $known->{$parent}) {