This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix a nested package deletion bug
authorFather Chrysostomos <sprout@cpan.org>
Wed, 20 Oct 2010 06:50:07 +0000 (23:50 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 21 Oct 2010 12:56:52 +0000 (05:56 -0700)
In mro_package_moved, I was calling mro_isa_changed_in, instead
of mro_package_moved, for a deleted package. So its subpackages
were ignored.

Exempli gratia, delete $::{'Cur::'} would call mro_isa_changed_in on
Cur::Cur, but ignore Cur::Cur::Cur.

I probably added this bug (or reinstated it, as it was in 5.13.5) in
d056e33c1.

mro.c
t/mro/package_aliases.t

diff --git a/mro.c b/mro.c
index 830ef5a..b065d70 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -671,7 +671,9 @@ Perl_mro_package_moved(pTHX_ HV * const stash, const HV * const oldstash,
                         substash, oldsubstash, NULL, NULL, level-1
                        );
                    else if(oldsubstash && HvNAME(oldsubstash))
-                       mro_isa_changed_in(oldsubstash);
+                       mro_package_moved(
+                        NULL, oldsubstash, NULL, NULL, level-1
+                       );
 
                    (void)hv_store(seen, key, len, &PL_sv_yes, 0);
                }
index 8b54ebd..991c672 100644 (file)
@@ -10,7 +10,7 @@ BEGIN {
 
 use strict;
 use warnings;
-plan(tests => 16);
+plan(tests => 18);
 
 {
     package New;
@@ -192,6 +192,26 @@ for(
  is $pet->speak, 'Woof!',
   'the deleted stash is gone completely when freed';
 }
+# Same thing, but with nested packages
+{
+ @Pett::ISA = ("Curr::Curr::Curr", "Hownd");
+ @Curr::Curr::Curr::ISA = "Latrator";
+
+ sub Latrator::speak { "Arff!" }
+ sub Hownd::speak { "Woof!" }
+
+ my $pet = bless [], "Pett";
+
+ my $life_raft = delete $::{'Curr::'};
+
+ is $pet->speak, 'Woof!',
+  'deleting a stash from its parent stash resets caches of substashes';
+
+ undef $life_raft;
+ is $pet->speak, 'Woof!',
+  'the deleted substash is gone completely when freed';
+}
+
 
 # mro_package_moved needs to check for self-referential packages.
 # This broke Text::Template [perl #78362].