diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-11-26 18:00:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-11-26 18:00:05 +0000 |
commit | 1ff09fbafb1bac228ed8d2a6d60971f9319e4977 (patch) | |
tree | ae1f8d64c976bbbe807f0f13307bfd1dda41b644 /lib/Carp | |
parent | fa12c845b2bb06d05b772383ebab8b08967cf98f (diff) | |
download | perl-1ff09fbafb1bac228ed8d2a6d60971f9319e4977.tar.gz |
Make the cache in Carp::trusts actually persist across calls :-)
I made a similar mistake once long ago, and now spot the pattern.
p4raw-id: //depot/perl@29385
Diffstat (limited to 'lib/Carp')
-rw-r--r-- | lib/Carp/Heavy.pm | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Carp/Heavy.pm b/lib/Carp/Heavy.pm index 2caeb273bb..a293b59a09 100644 --- a/lib/Carp/Heavy.pm +++ b/lib/Carp/Heavy.pm @@ -224,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; { @@ -274,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}) { |