-
Notifications
You must be signed in to change notification settings - Fork 578
->isa broken in 5.6.0 #1498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From [email protected]Created by [email protected]Tk's overly complex AUTOLOAD has this code in it: if (!defined(&$what) && With perl5.6.0 the $_[0]->isa('Tk::Widget') is returning FALSE. Printing : Gives: As I would expect. The case in point is Tk::Frame which starts thus: package Tk::Frame; use base qw(Tk::Derived Tk::Widget); Perl Info
|
From [Unknown Contact. See original ticket]Nick Ing-Simmons <nick@ni-s.u-net.com> writes:
Here is a testcase: package Bar; sub AUTOLOAD sub new package Foo; sub Thing { } package FooBar; use base qw(Foo Bar); package main; my $obj = FooBar::->new; $obj->Doit;
|
From @sciuriusNick Ing-Simmons <nick@ni-s.u-net.com> writes:
Could this be related to bug [ID 20000321.016] use base / our @ISA -- Johan |
From [Unknown Contact. See original ticket]Nick Ing-Simmons <nick@ing-simmons.net> writes:
It is unreleated to AUTOLOAD. next if $pkg->isa($base); Combined with S_isa_lookup()'s use of ::ISA::CACHE::. Thus with 5.6.0 if you The attached patch clears the cache whenever anything is Role on 5.6.1 ;-) -- |
From [Unknown Contact. See original ticket]Inline Patch--- lib/base.pm.ship Sat Mar 25 15:51:06 2000
+++ lib/base.pm Sat Mar 25 16:00:52 2000
@@ -45,7 +45,7 @@
package base;
use 5.005_64;
-our $VERSION = "1.01";
+our $VERSION = "1.02";
sub import {
my $class = shift;
@@ -55,6 +55,7 @@
foreach my $base (@_) {
next if $pkg->isa($base);
push @{"$pkg\::ISA"}, $base;
+ delete ${"$pkg\::"}{'::ISA::CACHE::'};
unless (exists ${"$base\::"}{VERSION}) {
eval "require $base";
# Only ignore "Can't locate" errors from our eval require. |
From @gsarOn Sat, 25 Mar 2000 16:11:04 GMT, Nick Ing-Simmons wrote:
It seems to me this caching is conceptually flawed. This fails to package Bar; The basic problem here is that the cache can never be updated when
This won't work when @ISA is manipulated directly as above. Worse, package Baz; $Baz::VERSION++; I think the caching done by UNIVERSAL::isa() should be fixed instead Sarathy |
From @gsarOn Sat, 25 Mar 2000 08:47:53 PST, Gurusamy Sarathy wrote:
Oops, must be: $Bar::VERSION++ Sarathy |
From [Unknown Contact. See original ticket]Johan Vromans <JVromans@squirrel.nl> writes:
Seems to be the same bug:
Prints nothing with 5.6.0 nick@bactrian:~/p5/perl-5.6.0 > ./perl -Ilib /tmp/bug2 As you expected. Without the 'our' S_isa_lookup() exits without any caching activity. None the less declaring @ISA like that is un-useful. The robust fix might be to make @ISA's existing 'magic' -- |
From [Unknown Contact. See original ticket]
That's one reason why I never use "Baz". In the sequence Foo/Bar/Glarch, (Plus I "grew up" on Glarch as the third item, and only heard Baz But I think the "how far away is it" thing is enough. --tom |
From [Unknown Contact. See original ticket]Gurusamy Sarathy <gsar@ActiveState.com> writes:
I agree 100% now I have investigated some more. -- |
From @gsarOn Sat, 25 Mar 2000 17:14:40 GMT, Nick Ing-Simmons wrote:
s/the cache and delete it/all the invalidated caches and delete them/. :-)
This is probably easier. Finding the all the subclasses (in order to But if we add the infrastructure to do the latter, it would probably Sarathy |
From [Unknown Contact. See original ticket]Gurusamy Sarathy <gsar@ActiveState.com> writes:
Attached patch to universal.c stores PL_sub_generation in the scalar -- |
From [Unknown Contact. See original ticket]Inline Patch--- universal.c.ship Sat Mar 25 14:44:19 2000
+++ universal.c Thu Mar 30 16:34:26 2000
@@ -14,6 +14,7 @@
GV* gv;
GV** gvp;
HV* hv = Nullhv;
+ SV* subgen = Nullsv;
if (!stash)
return &PL_sv_undef;
@@ -26,17 +27,26 @@
gvp = (GV**)hv_fetch(stash, "::ISA::CACHE::", 14, FALSE);
- if (gvp && (gv = *gvp) != (GV*)&PL_sv_undef && (hv = GvHV(gv))) {
- SV* sv;
- SV** svp = (SV**)hv_fetch(hv, name, len, FALSE);
- if (svp && (sv = *svp) != (SV*)&PL_sv_undef)
- return sv;
+ if (gvp && (gv = *gvp) != (GV*)&PL_sv_undef && (subgen = GvSV(gv)) && (hv = GvHV(gv))) {
+ if (SvIV(subgen) == PL_sub_generation) {
+ SV* sv;
+ SV** svp = (SV**)hv_fetch(hv, name, len, FALSE);
+ if (svp && (sv = *svp) != (SV*)&PL_sv_undef) {
+ DEBUG_o( Perl_deb(aTHX_ "Using cached ISA %s for package %s\n",name,HvNAME(stash)) );
+ return sv;
+ }
+ }
+ else {
+ DEBUG_o( Perl_deb(aTHX_ "ISA Cache in package %s is stale\n",HvNAME(stash)) );
+ hv_clear(hv);
+ sv_setiv(subgen, PL_sub_generation);
+ }
}
gvp = (GV**)hv_fetch(stash,"ISA",3,FALSE);
-
+
if (gvp && (gv = *gvp) != (GV*)&PL_sv_undef && (av = GvAV(gv))) {
- if(!hv) {
+ if(!hv || !subgen) {
gvp = (GV**)hv_fetch(stash, "::ISA::CACHE::", 14, TRUE);
gv = *gvp;
@@ -44,7 +54,12 @@
if (SvTYPE(gv) != SVt_PVGV)
gv_init(gv, stash, "::ISA::CACHE::", 14, TRUE);
- hv = GvHVn(gv);
+ if (!hv)
+ hv = GvHVn(gv);
+ if (!subgen) {
+ subgen = newSViv(PL_sub_generation);
+ GvSV(gv) = subgen;
+ }
}
if(hv) {
SV** svp = AvARRAY(av);
@@ -88,10 +103,10 @@
{
char *type;
HV *stash;
-
+
stash = Nullhv;
type = Nullch;
-
+
if (SvGMAGICAL(sv))
mg_get(sv) ;
@@ -104,7 +119,7 @@
else {
stash = gv_stashsv(sv, FALSE);
}
-
+
return (type && strEQ(type,name)) ||
(stash && isa_lookup(stash, name, strlen(name), 0) == &PL_sv_yes)
? TRUE
--- t/op/universal.t.ship Thu Mar 30 15:33:02 2000
+++ t/op/universal.t Thu Mar 30 16:35:21 2000
@@ -6,9 +6,10 @@
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib' if -d '../lib';
+ $| = 1;
}
-print "1..73\n";
+print "1..80\n";
$a = {};
bless $a, "Bob";
@@ -28,6 +29,18 @@
$Alice::VERSION = 2.718;
+{package Cedric;
+ our @ISA;
+ use base qw(Human);
+}
+
+{package Programmer;
+ our $VERSION = 1.667;
+
+ sub write_perl { 1 }
+}
+
+
package main;
my $i = 2;
@@ -45,12 +58,33 @@
test ! $a->isa("Male");
+test ! $a->isa('Programmer');
+
test $a->can("drink");
test $a->can("eat");
test ! $a->can("sleep");
+test (!Cedric->isa('Programmer'));
+
+test (Cedric->isa('Human'));
+
+push(@Cedric::ISA,'Programmer');
+
+test (Cedric->isa('Programmer'));
+
+{package Alice;
+ base::->import('Programmer');
+}
+
+test $a->isa('Programmer');
+test $a->isa("Female");
+
+@Cedric::ISA = qw(Bob);
+
+test (!Cedric->isa('Programmer'));
+
my $b = 'abc';
my @refs = qw(SCALAR SCALAR LVALUE GLOB ARRAY HASH CODE);
my @vals = ( \$b, \3.14, \substr($b,1,1), \*b, [], {}, sub {} );
@@ -88,7 +122,7 @@
test $a->isa("UNIVERSAL");
-my $sub2 = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::;
+my $sub2 = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::;
# XXX import being here is really a bug
if ('a' lt 'A') {
test $sub2 eq "can import isa VERSION"; |
Migrated from rt.perl.org#2711 (status was 'resolved')
Searchable as RT2711$
The text was updated successfully, but these errors were encountered: