diff options
author | Father Chrysostomos <sprout@cpan.org> | 2016-09-04 14:22:37 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2016-09-04 14:29:09 -0700 |
commit | bdc377e5e0c60dfb539423e956843489501ca2bd (patch) | |
tree | 83b6f39eee74b52500f4b6953010570938a29733 /perly.y | |
parent | ba0a4150f6f1604df236035adf6df18bd43de88e (diff) | |
download | perl-bdc377e5e0c60dfb539423e956843489501ca2bd.tar.gz |
[perl #129073] Assert failure: ${p{};sub p}()
When parsing the special ${var{subscript}} syntax, the lexer notes
that the } matching the ${ will be a fake bracket, and should
be ignored.
In the case of ${p{};sub p}() the first syntax error causes tokens to
be popped, such that the } following the sub declaration ends up being
the one treated as a fake bracket and ignored.
The part of the lexer that deals with sub declarations treats a ( fol-
lowing the sub name as a prototype (which is a single term) if signa-
tures are disabled, but ignores it and allows the rest of the lexer to
treat it as a parenthesis if signatures are enabled.
Hence, the part of the parser (perly.y) that parses signatures knows
that a parenthesis token can only come after a sub if signatures are
enabled, and asserts as much.
In the case of an error and tokens being discarded, a parenthesis may
come after a sub name as far as the parser is concerned, even though
there was a } in between that got discarded. The sub part of the
lexer, of course did not see the parenthesis because of the interven-
ing brace, and did not treat it as a prototype. So we get an asser-
tion failure.
The simplest fix is to loosen up the assertion and allow for anomalies
after errors. It does not hurt to go ahead and parse a signature at
this point, even though the feature is disabled, because there has
been a syntax error already, so the parsed code will never run, and
the parsed sub will not be installed.
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -788,7 +788,9 @@ subsignature: '(' UNOP_AUX_item *aux; OP *check; - assert(FEATURE_SIGNATURES_IS_ENABLED); + if (!parser->error_count) { + assert(FEATURE_SIGNATURES_IS_ENABLED); + } /* We shouldn't get here otherwise */ Perl_ck_warner_d(aTHX_ |