Skip to content

Commit

Permalink
Make delete $package::{ISA} work
Browse files Browse the repository at this point in the history
  • Loading branch information
Father Chrysostomos committed Nov 13, 2010
1 parent beeda14 commit f3d2f32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 7 additions & 3 deletions hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
entry = *oentry;
for (; entry; oentry = &HeNEXT(entry), entry = *oentry) {
SV *sv;
bool mpm = FALSE;
U8 mro_changes = 0; /* 1 = isa; 2 = package moved */
const char *name = NULL;
STRLEN namlen;
HV *stash = NULL;
Expand Down Expand Up @@ -1044,7 +1044,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
gv_fetchsv(namesv, GV_NOADD_NOINIT, SVt_PVGV)
== (GV *)sv
) {
mpm = TRUE;
mro_changes = 2;
name = SvPV_const(namesv, namlen);
namlen -= 2; /* skip trailing :: */
/* Hang on to it for a bit. */
Expand All @@ -1053,6 +1053,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
);
}
}
else if (klen == 3 && strnEQ(key, "ISA", 3))
mro_changes = 1;
}

if (d_flags & G_DISCARD)
Expand Down Expand Up @@ -1085,7 +1087,9 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
HvHASKFLAGS_off(hv);
}

if (mpm) mro_package_moved(NULL, stash, NULL, name, namlen);
if (mro_changes == 1) mro_isa_changed_in(hv);
else if (mro_changes == 2)
mro_package_moved(NULL, stash, NULL, name, namlen);

return sv;
}
Expand Down
10 changes: 9 additions & 1 deletion t/mro/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
use warnings;

BEGIN { require q(./test.pl); } plan(tests => 50);
BEGIN { require q(./test.pl); } plan(tests => 51);

require mro;

Expand Down Expand Up @@ -312,3 +312,11 @@ is(eval { MRO_N->testfunc() }, 123);
ok 'Extra::TSpouse'->isa('Class::Trait::Base'),
'a isa b after undef *a::ISA and @a::ISA modification';
}

{
# Deleting $package::{ISA}
# Broken in 5.10.0; fixed in 5.13.7
@Blength::ISA = 'Bladd';
delete $Blength::{ISA};
ok !Blength->isa("Bladd"), 'delete $package::{ISA}';
}

0 comments on commit f3d2f32

Please sign in to comment.