File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,17 @@ Perl_class_setup_stash(pTHX_ HV *stash)
251251 HEKfARG (HvNAME_HEK (stash )));
252252 }
253253
254+ {
255+ SV * isaname = newSVpvf ("%" HEKf "::ISA" , HvNAME_HEK (stash ));
256+ sv_2mortal (isaname );
257+
258+ AV * isa = get_av (SvPV_nolen (isaname ), (SvFLAGS (isaname ) & SVf_UTF8 ));
259+
260+ if (isa && av_count (isa ) > 0 )
261+ croak ("Cannot create class %" HEKf " as it already has a non-empty @ISA" ,
262+ HvNAME_HEK (stash ));
263+ }
264+
254265 char * classname = HvNAME (stash );
255266 U32 nameflags = HvNAMEUTF8 (stash ) ? SVf_UTF8 : 0 ;
256267
Original file line number Diff line number Diff line change @@ -713,6 +713,12 @@ no legal conversion from that type of reference to a typeglob.
713713(P) Perl detected an attempt to copy a value to an internal type that cannot
714714be directly assigned to.
715715
716+ =item Cannot create class %s as it already has a non-empty @ISA
717+
718+ (F) An attempt was made to create a class out of a package that already has
719+ an C<@ISA> array, and the array is not empty. This is not permitted, as it
720+ would lead to a class with inconsistent inheritance.
721+
716722=item Cannot find encoding "%s"
717723
718724(S io) You tried to apply an encoding that did not exist to a filehandle,
Original file line number Diff line number Diff line change @@ -80,3 +80,10 @@ class XXX {}
8080push @XXX::ISA, q(Another);
8181EXPECT
8282Modification of a read-only value attempted at - line 4.
83+ ########
84+ no warnings 'experimental::class';
85+ use feature 'class';
86+ BEGIN { push @XXX::ISA, q(Another); }
87+ class XXX {}
88+ EXPECT
89+ Cannot create class XXX as it already has a non-empty @ISA at - line 4.
You can’t perform that action at this time.
0 commit comments