This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use the right outside for my subs defined in inner subs
authorFather Chrysostomos <sprout@cpan.org>
Wed, 15 Aug 2012 01:10:40 +0000 (18:10 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 16 Sep 2012 05:45:06 +0000 (22:45 -0700)
commit8d88fe29d7f8e580970ac5a994ba499606884c4c
treeeca6eb43763fb897414eecf6012775c096cc6d47
parent2156df4b70c69d07326f7b43b71b66509ee87db5
Use the right outside for my subs defined in inner subs

In this example,

{
  my sub foo;
  sub bar {
    sub foo { }
  }
}

the foo sub is cloned when the scope containing the ‘my sub’ declara-
tion is entered, but foo’s CvOUTSIDE pointer points to something other
than the active sub.  cv_clone assumes that the currently-running sub
is the right sub to close over (at least for subs; formats are another
matter).  That was true in the absence of my subs.  This commit
changes it to account.

I had to tweak the test, which was wrong, because sub foo was closing
over a stale var.
pad.c
t/cmd/lexsub.t