This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Invalidate method cache on C<local *subname>
[perl5.git] / scope.c
diff --git a/scope.c b/scope.c
index 7a0a578..5958aba 100644 (file)
--- 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: