summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scope.c2
-rw-r--r--t/lib/warnings/pad10
2 files changed, 11 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index 673a312900..ff45b0da43 100644
--- a/scope.c
+++ b/scope.c
@@ -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 {