This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
change #31447 was wrong. Really handle cloning a stale lexical var
[perl5.git] / pad.c
diff --git a/pad.c b/pad.c
index 6e33495..cfd3787 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -1494,17 +1494,17 @@ Perl_cv_clone(pTHX_ CV *proto)
            if (SvFAKE(namesv)) {   /* lexical from outside? */
                sv = outpad[PARENT_PAD_INDEX(namesv)];
                assert(sv);
-               /* formats may have an inactive parent */
-               if (SvTYPE(proto) == SVt_PVFM && SvPADSTALE(sv)) {
+               /* formats may have an inactive parent,
+                  while my $x if $false can leave an active var marked as
+                  stale */
+               if (SvPADSTALE(sv)) {
                    if (ckWARN(WARN_CLOSURE))
                        Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
                            "Variable \"%s\" is not available", SvPVX_const(namesv));
                    sv = NULL;
                }
-               /* 'my $x if $y' can leave $x stale even in an active sub */
-               else if (!SvPADSTALE(sv)) {
+               else 
                    SvREFCNT_inc_simple_void_NN(sv);
-               }
            }
            if (!sv) {
                 const char sigil = SvPVX_const(namesv)[0];