PERL_UNUSED_ARG(old_cv);
for (ix = PadnamelistMAX(comppad_name); ix > 0; ix--) {
- const PADNAME * const name = namepad[ix];
- if (name && name != &PL_padname_undef && !PadnameIsSTATE(name)
+ const PADNAME *name = namepad[ix];
+ if (name && name != &PL_padname_undef && !PadnameIsOUR(name)
&& *PadnamePV(name) == '&')
{
- if (SvTYPE(curpad[ix]) == SVt_PVCV) {
+ CV *innercv = MUTABLE_CV(curpad[ix]);
+ if (UNLIKELY(PadnameOUTER(name))) {
+ CV *cv = new_cv;
+ PADNAME **names = namepad;
+ PADOFFSET i = ix;
+ while (PadnameOUTER(name)) {
+ cv = CvOUTSIDE(cv);
+ names = PadlistNAMESARRAY(CvPADLIST(cv));
+ i = PARENT_PAD_INDEX(name);
+ name = names[i];
+ }
+ innercv = (CV *)PadARRAY(PadlistARRAY(CvPADLIST(cv))[1])[i];
+ }
+ if (SvTYPE(innercv) == SVt_PVCV) {
/* XXX 0afba48f added code here to check for a proto CV
attached to the pad entry by magic. But shortly there-
after 81df9f6f95 moved the magic to the pad name. The
code here was never updated, so it wasn’t doing anything
and got deleted when PADNAME became a distinct type. Is
there any bug as a result? */
- CV * const innercv = MUTABLE_CV(curpad[ix]);
if (CvOUTSIDE(innercv) == old_cv) {
if (!CvWEAKOUTSIDE(innercv)) {
SvREFCNT_dec(old_cv);
*bar::is = *is;
*bar::like = *like;
}
-plan 147;
+plan 148;
# -------------------- Errors with feature disabled -------------------- #
like $@, qr/^Undefined subroutine &φου called at /,
'state sub with utf8 name';
}
+# This used to crash, but only as a standalone script
+is runperl(switches => ['-lXMfeature=:all'],
+ prog => '$::x = global=>;
+ sub x;
+ sub x {
+ state $x = 42;
+ state sub x { print eval q|$x| }
+ x()
+ }
+ x()',
+ stderr => 1), "42\n",
+ 'closure behaviour of state sub in predeclared package sub';
# -------------------- my -------------------- #