These are combined into one patch because it is hard to fix one with-
out fixing the other.
local *glob = $ref was ignoring the clobbered reference and not
accounting for when updating ISA caches, resulting in two bugs:
*Foo::ISA = *Bar::ISA;
@Foo::ISA = "Baz";
sub Baz::ook { "Baz" }
sub L::ook { "See" }
warn Bar->ook; # Baz
local *Foo::ISA = ["L"];
warn Bar->ook; # Baz
@Baz::ISA = @Baz::ISA; # should have no effect
warn Bar->ook; # See
@Baz::ISA = "Foo::bar";
sub Foo::bar::ber { 'baz' }
sub UNIVERSAL::ber { "black sheep" }
warn Baz->ber; # baz
local *Foo:: = \%Bar::;
warn Baz->ber; # baz
@Baz::ISA = @Baz::ISA; # should have no effect
warn Baz->ber; # black sheep
The dref variable in sv.c:S_glob_assign_ref holds the SV that needs to
be freed. So during localisation it is NULL.
When I was fixing up isa and mro bugs in perl 5.14, I misunderstood
its purpose and thought it always contained the reference on the left.
Since we need to have access to what was assigned over after the
assignment, this commit changes dref always to hold the clobbered SV,
and makes the SvREFCNT_dec conditional.
S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
{
SV * const sref = SvRV(sstr);
- SV *dref = NULL;
+ SV *dref;
const int intro = GvINTRO(dstr);
SV **location;
U8 import_flag = 0;
}
SAVEGENERICSV(*location);
}
- else
- dref = *location;
+ dref = *location;
if (stype == SVt_PVCV && (*location != sref || GvCVGEN(dstr))) {
CV* const cv = MUTABLE_CV(*location);
if (cv) {
}
break;
}
- SvREFCNT_dec(dref);
+ if (!intro) SvREFCNT_dec(dref);
if (SvTAINTED(sstr))
SvTAINT(dstr);
return;
BEGIN { chdir 't'; @INC = '../lib'; require './test.pl' }
-plan 12;
+plan 13;
@Foogh::ISA = "Bar";
*Phoogh::ISA = *Foogh::ISA;
'!isa when another stash has claimed the @ISA via ref-to-glob assignment';
ok !Phoo->isa("Bar"),
'!isa on the stash that claimed the @ISA via ref-to-glob assignment';
+
+*Fooo::ISA = *Baro::ISA;
+@Fooo::ISA = "Bazo";
+sub Bazo::ook { "Baz" }
+sub L::ook { "See" }
+Baro->ook;
+local *Fooo::ISA = ["L"];
+is 'Baro'->ook, 'See', 'localised *ISA=$ref assignment';
use strict;
use warnings;
-plan(tests => 52);
+plan(tests => 53);
{
package New;
'isa(foo) when inheriting from "class:" after string-to-glob assignment';
}
-
+@Bazo::ISA = "Fooo::bar";
+sub Fooo::bar::ber { 'baz' }
+sub UNIVERSAL::ber { "black sheep" }
+Bazo->ber;
+local *Fooo:: = \%Baro::;
+{
+ no warnings;
+ is 'Bazo'->ber, 'black sheep', 'localised *glob=$stashref assignment';
+}