This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[ PATCH] Re: isa(UNIVERSAL)?
authorDave Mitchell <davem@fdisolutions.com>
Thu, 17 Jul 2003 21:51:12 +0000 (22:51 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 18 Jul 2003 06:21:15 +0000 (06:21 +0000)
Message-ID: <20030717205112.GA2994@fdgroup.com>

p4raw-id: //depot/perl@20168

t/op/universal.t
universal.c

index 7d5f59a..71daf67 100755 (executable)
@@ -9,7 +9,7 @@ BEGIN {
     $| = 1;
 }
 
-print "1..98\n";
+print "1..100\n";
 
 $a = {};
 bless $a, "Bob";
@@ -187,3 +187,11 @@ test ! UNIVERSAL::isa("\xff\xff\xff\0", 'HASH');
     ::test $x->isa("Human");
     ::test $x->can("eat");
 }
+
+# bugid 3284
+# a second call to isa('UNIVERSAL') when @ISA is null failed due to caching
+
+@X::ISA=();
+my $x = {}; bless $x, 'X';
+test $x->isa('UNIVERSAL');
+test $x->isa('UNIVERSAL');
index b4563e4..9ee3e21 100644 (file)
@@ -45,6 +45,9 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
     if (strEQ(HvNAME(stash), name))
        return &PL_sv_yes;
 
+    if (strEQ(name, "UNIVERSAL"))
+       return &PL_sv_yes;
+
     if (level > 100)
        Perl_croak(aTHX_ "Recursive inheritance detected in package '%s'",
                   HvNAME(stash));
@@ -112,8 +115,7 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
            (void)hv_store(hv,name,len,&PL_sv_no,0);
        }
     }
-
-    return boolSV(strEQ(name, "UNIVERSAL"));
+    return &PL_sv_no;
 }
 
 /*