This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate inlining sub(){$x} if $x is changed elsewhere
authorFather Chrysostomos <sprout@cpan.org>
Sat, 1 Nov 2014 14:07:36 +0000 (07:07 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 13 Nov 2014 12:49:38 +0000 (04:49 -0800)
commit0ac016fc68a8b6f210ddacb62494e53da203c571
tree25a223ed56d7a4b515fc209a97e6ca9d3c88cc36
parent0b2df18fd3736ebdac552d596b8976109f9f4643
Deprecate inlining sub(){$x} if $x is changed elsewhere

With the new PadnameLVALUE flag, we can detect cases where an outer
lexical is used multiple times in lvalue context.  If the subroutine
contains just a lexical variable and nothing else, deprecate this
behaviour, so we can change it not to break the closure pattern at
some future date.

Future commits will fix those cases where the subroutine contains more
than just a lexical variable, without a deprecation cycle.

Adding this code to op_const_sv doesn’t really make sense.  More to
the point, having S_cv_clone_pad call op_const_sv doesn’t make sense,
but changing that (moving this code directly to S_cv_clone_pad) will
require other refactorings to avoid breaking some cases of constant
(real constant)  inlining, such as sub(){$x++ if 0; 3}, which cur-
rently gets inlined.
embed.fnc
embed.h
op.c
pad.c
pod/perldiag.pod
proto.h
t/op/const-optree.t