This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #128171] Fix assert fail with /@0{0*->@*/*0
authorFather Chrysostomos <sprout@cpan.org>
Wed, 18 May 2016 01:16:52 +0000 (18:16 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 18 May 2016 03:29:11 +0000 (20:29 -0700)
commitd674449463a15ac3f36086e3a0bb3a9d02729887
tree6116b630dd91edfe8f0c9b7fee3c13d78889ee4a
parent7832ad859a7fe7ff3d13488cd9bd5fc210c12ccd
[perl #128171] Fix assert fail with /@0{0*->@*/*0

If a syntax error such as * (multiply) followed by an arrow causes the
parser to pop scopes in trying to recover from the error, it might
exit the quote-parsing scope (for parsing the regexp) and point the
lexer’s cursor at the code following the regexp, after the lexer has
noted to itself that it is expected to parse a postfix dereference
(PL_expect==XPOSTDEREF).

The code for parsing a postfix dereference has an assertion which
ends up failing in this case, because the *0 following the regexp,
having sigil that can come after an arrow, goes through the postfix
deref function, which complains about the 0 it did not expect.

If we simply remove the assertion, the lexer will continue to emit
tokens, and we just end up dying (somewhat) gracefully because of the
syntax error, instead of crashing.

I used a ] in the test instead of a final 0, to avoid a compile-
time warning.  (Number found where operator expected.)
t/base/lex.t
toke.c