This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Only call mro_package_moved on new substashes
[perl5.git] / gv.c
diff --git a/gv.c b/gv.c
index 691dbba..b2cb5a4 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1072,9 +1072,17 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
                    return NULL;
 
                if (!(stash = GvHV(gv)))
+               {
                    stash = GvHV(gv) = newHV();
-
-               if (!HvNAME_get(stash))
+                   if (!HvNAME_get(stash)) {
+                       hv_name_set(stash, nambeg, name_cursor-nambeg, 0);
+                       /* If the containing stash has multiple effective
+                          names, see that this one gets them, too. */
+                       if (HvAUX(GvSTASH(gv))->xhv_name_count)
+                           mro_package_moved(stash, NULL, gv, 1);
+                   }
+               }
+               else if (!HvNAME_get(stash))
                    hv_name_set(stash, nambeg, name_cursor - nambeg, 0);
            }
 
@@ -2628,7 +2636,7 @@ Perl_gv_try_downgrade(pTHX_ GV *gv)
 
     /* XXX Why and where does this leave dangling pointers during global
        destruction? */
-    if (PL_dirty) return;
+    if (PL_phase == PERL_PHASE_DESTRUCT) return;
 
     if (!(SvREFCNT(gv) == 1 && SvTYPE(gv) == SVt_PVGV && !SvFAKE(gv) &&
            !SvOBJECT(gv) && !SvREADONLY(gv) &&