I don’t believe this changes any observable behaviour, Devel::Peek
aside. If it does, it fixes bugs.
I am making this change for two reasons:
• PADTMPs can be a bit buggy and letting them escape their subroutines
can make the bugs harder to fix.
• This brings explicit and implicit return from lvalue subroutines one
step closer (for the sake of merging the code).
S_return_lvalues(pTHX_ SV **mark, SV **sp, SV **newsp, I32 gimme,
PERL_CONTEXT *cx)
{
+ const bool ref = !!(CxLVAL(cx) & OPpENTERSUB_INARGS);
if (gimme == G_SCALAR) {
if (MARK < SP) {
if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) {
}
else if (gimme == G_ARRAY) {
assert (!(CxLVAL(cx) & OPpENTERSUB_DEREF));
- if (!CxLVAL(cx) || CxLVAL(cx) & OPpENTERSUB_INARGS)
+ if (ref || !CxLVAL(cx))
while (++MARK <= SP)
*++newsp =
SvTEMP(*MARK)
? *MARK
- : sv_2mortal(SvREFCNT_inc_simple_NN(*MARK));
+ : ref && SvFLAGS(*MARK) & SVs_PADTMP
+ ? sv_mortalcopy(*MARK)
+ : sv_2mortal(SvREFCNT_inc_simple_NN(*MARK));
else while (++MARK <= SP) {
*++newsp = *MARK;
}