summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2008-01-19 20:41:03 +0000
committerDave Mitchell <davem@fdisolutions.com>2008-01-19 20:41:03 +0000
commitd11865445af8750ad2c09674e81b7941117e83b5 (patch)
tree474c35749910dfc3c197dde2206dca35a12dfa7a /pad.c
parent47031da69d9704a7f7f2f86084deec4a32cbaf6e (diff)
downloadperl-d11865445af8750ad2c09674e81b7941117e83b5.tar.gz
[perl #49522] state variable not available
Svf_PADSTALE means something different for state vars. Make sure we always handle it correctly p4raw-id: //depot/perl@33009
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/pad.c b/pad.c
index cfd3787eb1..ea27408f3e 100644
--- a/pad.c
+++ b/pad.c
@@ -102,6 +102,8 @@ to be generated in evals, such as
{ my $x = 1; sub f { eval '$x'} } f();
+For state vars, SVf_PADSTALE is overloaded to mean 'not yet initialised'
+
=cut
*/
@@ -768,6 +770,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
else {
int newwarn = warn;
if (!CvCOMPILED(cv) && (*out_flags & PAD_FAKELEX_MULTI)
+ && !SvPAD_STATE(name_svp[offset])
&& warn && ckWARN(WARN_CLOSURE)) {
newwarn = 0;
Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
@@ -796,7 +799,9 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
"Pad findlex cv=0x%"UVxf" found lex=0x%"UVxf"\n",
PTR2UV(cv), PTR2UV(*out_capture)));
- if (SvPADSTALE(*out_capture)) {
+ if (SvPADSTALE(*out_capture)
+ && !SvPAD_STATE(name_svp[offset]))
+ {
if (ckWARN(WARN_CLOSURE))
Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
"Variable \"%s\" is not available", name);
@@ -853,7 +858,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
? SvSTASH(*out_name_sv) : NULL,
SvOURSTASH(*out_name_sv),
1, /* fake */
- 0 /* not a state variable */
+ SvPAD_STATE(*out_name_sv) ? 1 : 0 /* state variable ? */
);
new_namesv = AvARRAY(PL_comppad_name)[new_offset];
@@ -1496,8 +1501,8 @@ Perl_cv_clone(pTHX_ CV *proto)
assert(sv);
/* formats may have an inactive parent,
while my $x if $false can leave an active var marked as
- stale */
- if (SvPADSTALE(sv)) {
+ stale. And state vars are always available */
+ if (SvPADSTALE(sv) && !SvPAD_STATE(namesv)) {
if (ckWARN(WARN_CLOSURE))
Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
"Variable \"%s\" is not available", SvPVX_const(namesv));