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
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.