(int)(PL_dumpindent*level), "", (IV)SvREFCNT(sv),
(int)(PL_dumpindent*level), "");
+ if (flags & SVs_PADSTALE) sv_catpv(d, "PADSTALE,");
if (flags & SVs_PADTMP) sv_catpv(d, "PADTMP,");
if (flags & SVs_PADMY) sv_catpv(d, "PADMY,");
if (flags & SVs_TEMP) sv_catpv(d, "TEMP,");
SSCHECK(2);
SSPUSHLONG((long)(svp-PL_curpad));
SSPUSHINT(SAVEt_CLEARSV);
+ SvPADSTALE_off(*svp); /* mark lexical as active */
}
void
(void)SvOOK_off(sv);
break;
}
+ SvPADSTALE_on(sv); /* mark as no longer live */
}
else { /* Someone has a claim on this, so abandon it. */
U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
default: *(SV**)ptr = NEWSV(0,0); break;
}
SvREFCNT_dec(sv); /* Cast current value to the winds. */
- SvFLAGS(*(SV**)ptr) |= padflags; /* preserve pad nature */
+ /* preserve pad nature, but also mark as not live
+ * for any closure capturing */
+ SvFLAGS(*(SV**)ptr) |= padflags & SVs_PADSTALE;
}
break;
case SAVEt_DELETE:
#define SvUPGRADE(sv, mt) (SvTYPE(sv) >= mt || sv_upgrade(sv, mt))
-/* XXX spare */
+#define SVs_PADSTALE 0x00000100 /* lexical has gone out of scope */
#define SVs_PADTMP 0x00000200 /* in use as tmp */
#define SVs_PADMY 0x00000400 /* in use a "my" variable */
#define SVs_TEMP 0x00000800 /* string is stealable? */
#define SvTHINKFIRST(sv) (SvFLAGS(sv) & SVf_THINKFIRST)
+#define SvPADSTALE(sv) (SvFLAGS(sv) & SVs_PADSTALE)
+#define SvPADSTALE_on(sv) (SvFLAGS(sv) |= SVs_PADSTALE)
+#define SvPADSTALE_off(sv) (SvFLAGS(sv) &= ~SVs_PADSTALE)
+
#define SvPADTMP(sv) (SvFLAGS(sv) & SVs_PADTMP)
#define SvPADTMP_on(sv) (SvFLAGS(sv) |= SVs_PADTMP)
#define SvPADTMP_off(sv) (SvFLAGS(sv) &= ~SVs_PADTMP)