This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Preserve outside pointers of my subs with string eval
authorFather Chrysostomos <sprout@cpan.org>
Tue, 14 Aug 2012 05:56:05 +0000 (22:56 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 16 Sep 2012 05:45:06 +0000 (22:45 -0700)
The CvHASEVAL flag lets cv_clone know that the clone needs to have its
CvOUTSIDE pointer set, for the sake of string evals’ being able to
look up variables.

It was only being set on anonymous subs.  It should be set for all
clonable subs.  It doesn’t actually hurt to set it on all types of
subs, whether clonable or not, since it has no effect on non-clon-
able subs.

pad.c
t/cmd/lexsub.t

diff --git a/pad.c b/pad.c
index 960d725..941f663 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -1716,8 +1716,8 @@ Perl_pad_tidy(pTHX_ padtidy_type type)
                DEBUG_Xv(PerlIO_printf(Perl_debug_log,
                    "Pad clone on cv=0x%"UVxf"\n", PTR2UV(cv)));
                CvCLONE_on(cv);
-               CvHASEVAL_on(cv);
            }
+           CvHASEVAL_on(cv);
        }
     }
 
index f17eee0..7fc3e5c 100644 (file)
@@ -462,7 +462,6 @@ sub make_anon_with_my_sub{
     my sub s3 { eval '$x' }
     s3;
   }
-  local $::TODO = 'closure problem?';
   is s2, 3, 'my sub inside predeclared my sub';
 }