diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-20 09:23:35 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-20 20:17:18 -0800 |
commit | 34b54951568575920f2307bea918f5549bd5a82f (patch) | |
tree | aea97f1e1778d7276ecf9b14e817a5f77965109d /parser.h | |
parent | 05be69bb15d7a722ee6bca574d29b98314e34918 (diff) | |
download | perl-34b54951568575920f2307bea918f5549bd5a82f.tar.gz |
[perl #77452] Deparse { ...; BEGIN{} } correctly
8635e3c2 (5.21.6) changed the COP sequence numbers for nested blocks,
such that most BEGIN blocks (incl. ‘use’ statements) and sub declara-
tions end up in the right place. However, it had the side effect of
causing declarations at the end of the enclosing scope to fall out of
it and appear below.
This commit fixes that by adding an extra nulled COP to the end of the
enclosing scope if that scope ends with a sub, so the final declara-
tion gets deparsed before it.
The frequency of sub declarations at the end of the enclosing scope is
sufficiently low (I’m guessing a bit here) that this slight increase
in run-time memory usage is probably acceptable.
I had to change B::Deparse to deparse nulled COPs the same way it does
live COPs, which means we get more extraneous semicolons than before.
I hope to fix that in a forthcoming commit. I also ran into a B bug,
in that null ops are not presented to Perl code with the right op
class (see the blessing in the patch). I plan to fix that in a separ-
ate commit, too.
Diffstat (limited to 'parser.h')
-rw-r--r-- | parser.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -111,6 +111,7 @@ typedef struct yy_parser { PERL_BITFIELD16 in_pod:1; /* lexer is within a =pod section */ PERL_BITFIELD16 filtered:1; /* source filters in evalbytes */ PERL_BITFIELD16 saw_infix_sigil:1; /* saw & or * or % operator */ + PERL_BITFIELD16 parsed_sub:1; /* last thing parsed was a sub */ } yy_parser; /* flags for lexer API */ |