gv:gv_try_downgrade: Leave PL_last_in_gv alone
authorFather Chrysostomos <sprout@cpan.org>
Sun, 27 Oct 2013 23:02:44 +0000 (16:02 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 28 Oct 2013 23:15:09 +0000 (16:15 -0700)
commit2be08ad105a2a12613bb690aae26e2a9d3b225f2
tree5c31ac0d954d982518e19ae7231f613d34cd7bf8
parent722fa0e9973574787e686d761e198d8854b28688
gv:gv_try_downgrade: Leave PL_last_in_gv alone

gv_try_downgrade exists to remove globs and subs that were (possibly
temporarily) vivified by bareword lookup.  It is called whenever a
gvop is freed and its gv looks like a candidate for downgrading.  That
means it applies, not only to potential sub calls, but also to *foo
and *bar.  gv_try_downgrade may delete a glob from the stash alto-
gether if it is empty.  So eval "*foo if 0" may delete the *foo glob.

PL_last_in_gv is the internal variable underlying ${^LAST_FH}.  If
gv_try_downgrade deletes the last-read handle, then ${^LAST_FH}
will become undefined, whereas eval "*foo if 0" is not supposed to
do anything:

$ ./miniperl -le 'readline *{"foo"}; warn ${^LAST_FH}; eval "*foo if 0"; warn ${^LAST_FH}'
GLOB(0x7f8f5a0052a0) at -e line 1.
Warning: something's wrong at -e line 1.
gv.c
t/op/gv.t