This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #113872] Fix leavewrite’s stack handling
This commit fixes Scope::Escape compatibility by restoring the old
stack pointer stored on the context stack when exiting a write.
I don’t really understand why this fixes Scope::Escape, or rather, how
Scope::Escape ends up leaving some number of items on the stack other
than 1. But I *do* know this is the correct approach, as it mirrors
what pp_leavesub does in scalar context, but pops the stack back
to the old value (SP = newsp), rather than the old value+1 (see
pp_hot.c:pp_leavesub: MARK = newsp + 1; and later SP = MARK;). Then
the code that follows takes care of pushing write’s own return value.