summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c3
-rw-r--r--t/op/gv.t6
2 files changed, 7 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index 93e6ccc95b..c7453156ce 100644
--- a/gv.c
+++ b/gv.c
@@ -3320,7 +3320,8 @@ Perl_gv_try_downgrade(pTHX_ GV *gv)
!GvSV(gv) && !GvAV(gv) && !GvHV(gv) && !GvIOp(gv) && !GvFORM(gv) &&
GvEGVx(gv) == gv && (stash = GvSTASH(gv))))
return;
- if (gv == PL_statgv || gv == PL_stderrgv) return;
+ if (gv == PL_statgv || gv == PL_last_in_gv || gv == PL_stderrgv)
+ return;
if (SvMAGICAL(gv)) {
MAGIC *mg;
/* only backref magic is allowed */
diff --git a/t/op/gv.t b/t/op/gv.t
index 804ddd6d46..ef46951091 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
use warnings;
-plan( tests => 256 );
+plan( tests => 257 );
# type coercion on assignment
$foo = 'foo';
@@ -986,6 +986,10 @@ package lrcg {
-T _;
is "$!",$bang,
'try_downgrade does not touch PL_statgv (last stat handle)';
+ readline *{"try_downgrade2"};
+ my $lastfh = "${^LAST_FH}";
+ eval "*try_downgrade2 if 0";
+ is ${^LAST_FH}, $lastfh, 'try_downgrade does not touch PL_last_in_gv';
}
is runperl(prog => '$s = STDERR; close $s; undef *$s;'