diff options
-rw-r--r-- | scope.c | 2 | ||||
-rw-r--r-- | t/lib/warnings/pad | 10 |
2 files changed, 11 insertions, 1 deletions
@@ -945,7 +945,7 @@ Perl_leave_scope(pTHX_ I32 base) SvREFCNT_dec(sv); /* Cast current value to the winds. */ /* preserve pad nature, but also mark as not live * for any closure capturing */ - SvFLAGS(*(SV**)ptr) |= padflags & SVs_PADSTALE; + SvFLAGS(*(SV**)ptr) |= padflags | SVs_PADSTALE; } break; case SAVEt_DELETE: diff --git a/t/lib/warnings/pad b/t/lib/warnings/pad index 65f92c3c70..441fba29bd 100644 --- a/t/lib/warnings/pad +++ b/t/lib/warnings/pad @@ -149,6 +149,16 @@ f()->(); EXPECT Variable "$x" is not available at (eval 1) line 2. ######## +use warnings 'closure' ; +{ + my $x = 1; + $y = \$x; # force abandonment rather than clear-in-place at scope exit + sub f2 { eval '$x' } +} +f2(); +EXPECT +Variable "$x" is not available at (eval 1) line 2. +######## # pad.c no warnings 'closure' ; sub x { |