This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make &CORE::undef(\*_) undefine it properly
Unless called as &CORE::undef (without parentheses) after @_ has been
set to \*_, it leaves @_ in the ARRAY slot.
This is an implementation detail leaking through.
pp_entersub temporarily aliases @_ to a new array, which is restored
to its previous value on sub exit.
Since &CORE::undef is a perl sub with an op tree containing
an undef op,
$ ./perl -Ilib -MO=Concise,CORE::undef -e '\&CORE::undef'
CORE::undef:
3 <1> leavesublv[1 ref] K/REFC,1 ->(end)
2 <1> undef sKP/1 ->3
1 <$> coreargs(IV 44) s ->2
-e syntax OK
the undef op runs while @_ is localised.
So we should un-localise @_ if we detect that case.
Doing this in pp_coreargs might be a bit of a hack, but it’s less
code than rewriting &CORE::undef as an XSUB, which would be the
other option.
Either way, we need a special case, since undef is the only named op
that touches the ARRAY slot of the glob passed to it.