Fix @{*ISA} autovivification
authorFather Chrysostomos <sprout@cpan.org>
Fri, 13 Jul 2012 00:50:51 +0000 (17:50 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 13 Jul 2012 00:50:51 +0000 (17:50 -0700)
It was not attaching magic to the array, preventing subsequent changes
to the array from updating isa caches.

gv.c
t/mro/basic.t

diff --git a/gv.c b/gv.c
index ba8e85e..e0fdc63 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -83,6 +83,9 @@ Perl_gv_add_by_type(pTHX_ GV *gv, svtype type)
 
     if (!*where)
        *where = newSV_type(type);
+    if (type == SVt_PVAV && GvNAMELEN(gv) == 3
+     && strnEQ(GvNAME(gv), "ISA", 3))
+       sv_magic(*where, (SV *)gv, PERL_MAGIC_isa, NULL, 0);
     return gv;
 }
 
index e1a4dbf..188159e 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-BEGIN { require q(./test.pl); } plan(tests => 53);
+BEGIN { require q(./test.pl); } plan(tests => 54);
 
 require mro;
 
@@ -338,3 +338,10 @@ is(eval { MRO_N->testfunc() }, 123);
     ok !Gwythaint->isa("Fantastic::Creature"),
        'obliterating @ISA via glob assignment';
 }
+
+{
+    # Autovivifying @ISA via @{*ISA}
+    undef *fednu::ISA;
+    @{*fednu::ISA} = "pyfg";
+    ok +fednu->isa("pyfg"), 'autovivifying @ISA via *{@ISA}';
+}