If $x is not referenced or used in lvalue context elsewhere, then the
constant sub can actually share the same scalar as the enclosing sub’s
pad. It doesn’t need to copy. And we don’t in that case, as of
v5.21.5-421-g04472a8. But we need to make sure the PADTMP flag is
turned off at scope exit if the pad has the only reference to the sub.
(The PADTMP flag has been turned on as of v5.21.5-391-g5543332.)
SvFLAGS(sv) &=~ (SVf_OK|SVf_IVisUV|SVf_UTF8);
break;
}
+ SvPADTMP_off(sv);
SvPADSTALE_on(sv); /* mark as no longer live */
}
else { /* Someone has a claim on this, so abandon it. */
require './test.pl';
@INC = '../lib';
}
-plan 166;
+plan 167;
# @tests is an array of hash refs, each of which can have various keys:
#
&{$_{finally} or next}
}
+
+# This used to fail an assertion in leave_scope. For some reason, it did
+# not fail within the framework above.
+sub { my $x = "x"; my $sub = sub () { $x }; undef $sub; } ->();
+pass("No assertion failure when turning on PADSTALE on lexical shared by"
+ ." erstwhile constant");
+