Skip to content

Commit

Permalink
lval subs: do arg shifting in pp_return
Browse files Browse the repository at this point in the history
When an lvalue sub does an explicit return, currently pp_return
doesn't touch the args stack and instead tail calls S_return_lvalues()
which does both the leavesuby stuff (e.g. mortalise args) and the returny
stuff (e.g. shift the args down in list context).

Move the call to S_return_lvalues() further down in pp_return so that
the arg shifty stuff is done in pp_return now (like it is for non-lvalue
returns). This will allow us shortly to simply S_return_lvalues.
  • Loading branch information
iabyn committed Jun 19, 2015
1 parent 988f25b commit c32ac92
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pp_ctl.c
Expand Up @@ -2451,9 +2451,6 @@ PP(pp_return)
}

if (CxTYPE(cx) == CXt_SUB) {
if (CvLVALUE(cx->blk_sub.cv))
return S_return_lvalues(aTHX_ MARK);
else {
SV **oldsp = PL_stack_base + cx->blk_oldsp;
if (oldsp != MARK) {
/* Handle extra junk on the stack. For example,
Expand All @@ -2479,8 +2476,9 @@ PP(pp_return)
PL_stack_sp = oldsp;
}
/* fall through to a normal sub exit */
return Perl_pp_leavesub(aTHX);
}
return CvLVALUE(cx->blk_sub.cv)
? S_return_lvalues(aTHX_ NULL)
: Perl_pp_leavesub(aTHX);
}

POPBLOCK(cx,newpm);
Expand Down

0 comments on commit c32ac92

Please sign in to comment.