This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #97484] Make defined &{...} vivify CORE subs
authorFather Chrysostomos <sprout@cpan.org>
Thu, 1 Sep 2011 05:44:57 +0000 (22:44 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 1 Sep 2011 13:20:48 +0000 (06:20 -0700)
commit9da346da98617273964d333ee33ca5cdbddae4a1
treea4870ef2ca4ef8a9e1f6ce9456aaf9175e8447d0
parent7d953ba8a0841912423af9b3e7d1daef726d5fb0
[perl #97484] Make defined &{...} vivify CORE subs

Magical variables usually get autovivified, even in rvalue context,
because  Perl is trying to pretend they have been there all along.
That means defined(${"."}) will autovivify $. and return true.

Until CORE subs were introduced, there were no subroutines that popped
into existence when looked at.

This commit makes rv_2cv use the GV_ADDMG flag added in commit
23496c6ea.  When this flag is passed, gv_fetchpvn_flags creates a GV
but does not add it to the stash until it finds out that it is creat-
ing a magical one.  The CORE sub code calls newATTRSUB, which expects
to add the CV to the stash itself.  So the gv has to be added there
and then.  So gv_fetchpvn_flags is also adjusted to add the gv to the
stash right before calling newATTRSUB, and to tell itself that the
GV_ADDMG flag is actually off.

It might be better to move the CV-creation code into op.c and inline
parts of newATTRSUB, to avoid fiddling with the addmg variable (and
avoid prototype checks on CORE subs), but that refactoring should
probably come in separate commits.
gv.c
pp.c
sv.c
t/op/coresubs.t