This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
deparse pragmas before subs
Currently something like this:
use strict;
sub f {
print;
}
print;
deparses as:
sub f {
use strict;
print $_;
}
use strict;
print $_;
(Note where the 'strict's appear). Although ugly, this is semantically
correct for most pragmas. However, it breaks down for "use feature
'signatures'", since that needs to appear before the sub if the
deparsing of the sub's header is altered to reflect signature syntax or
not, based on whether the pragma is in scope.
This commit changes the deparsing of each nextstate op so that it outputs
any pragmas which reflect changes since the last nextstate's hints etc,
*before* deparsing any subs whose COP is less than that of the new
nextstate. After this commit, the code above deparses as:
use strict;
sub f {
print $_;
}
print $_;
It also allows some hacky code to be removed from Deparse.pm that
ensured that "no warnings experimental::lexical_subs" appeared before
each lexical sub was deparsed.
[ This fix is not comprehensive; a fuller fix comes in a few commits time ]