summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@pobox.com>1998-06-04 09:47:31 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-06-10 06:33:16 +0000
commit3d0588e9883a2e4f16306157ec1835a111d6ab4d (patch)
treed74d84d7a9ff9d13f4bfd9d6a3f04babc1d91f94
parentef7000ba83f7bda2531cf0d281b1f403638726ca (diff)
downloadperl-3d0588e9883a2e4f16306157ec1835a111d6ab4d.tar.gz
Invalidate method cache on C<local *subname>
Message-ID: <19980604134731.D24343@perlsupport.com> p4raw-id: //depot/perl@1097
-rw-r--r--scope.c5
-rwxr-xr-xt/op/method.t8
2 files changed, 12 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index 7a0a578e54..5958aba3f5 100644
--- a/scope.c
+++ b/scope.c
@@ -222,6 +222,9 @@ save_gp(GV *gv, I32 empty)
if (empty) {
register GP *gp;
+
+ if (GvCVu(gv))
+ sub_generation++; /* taking a method out of circulation */
Newz(602, gp, 1, GP);
GvGP(gv) = gp_ref(gp);
GvSV(gv) = NEWSV(72,0);
@@ -678,6 +681,8 @@ leave_scope(I32 base)
SvLEN(gv) = (STRLEN)SSPOPIV;
gp_free(gv);
GvGP(gv) = (GP*)ptr;
+ if (GvCVu(gv))
+ sub_generation++; /* putting a method back into circulation */
SvREFCNT_dec(gv);
break;
case SAVEt_FREESV:
diff --git a/t/op/method.t b/t/op/method.t
index d955705d1a..f1b1888ef6 100755
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -4,7 +4,7 @@
# test method calls and autoloading.
#
-print "1..24\n";
+print "1..26\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -66,6 +66,12 @@ test (A->d, "B::d4"); # Update hash table;
delete $B::{d}; # Should work without any help too
test (A->d, "C::d");
+{
+ local *C::d;
+ test (eval { A->d } || "nope", "nope");
+}
+test (A->d, "C::d");
+
*A::x = *A::d; # See if cache incorrectly follows synonyms
A->d;
test (eval { A->x } || "nope", "nope");