Bug #75252 [Opn->Csd]: Incorrect token formatting on two parse errors in one request
| From: | nikic@php.net | Date: | Sun, 24 Sep 2017 06:56:13 +0000 |
| Subject: | Bug #75252 [Opn->Csd]: Incorrect token formatting on two parse errors in one request | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211338@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75252&edit=1
ID: 75252
Updated by: nikic@php.net
Reported by: nikic@php.net
Summary: Incorrect token formatting on two parse errors in
one request
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.0.23
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=73d6456d7d6be62340b3607805a45cbf420c1cb8
Log: Fixed bug #75252
Previous Comments:
------------------------------------------------------------------------
[2017-09-24 06:46:13] nikic@php.net
Description:
------------
If two ParseErrors are thrown in the same request (e.g. by using eval or the ast extension), the
replacement of the token name with the token value is only performed for the first error.
This happens because the CG(parse_error) global does not get reset if the ParseError exception is
caught.
Test script:
---------------
<?php
$code = <<<'CODE'
function test_missing_semicolon() : string {
$x = []
FOO
}
CODE;
try {
eval($code);
} catch (ParseError $e) {
var_dump($e->getMessage());
}
try {
eval($code);
} catch (ParseError $e) {
var_dump($e->getMessage());
}
Expected result:
----------------
string(41) "syntax error, unexpected 'FOO' (T_STRING)"
string(41) "syntax error, unexpected 'FOO' (T_STRING)"
Actual result:
--------------
string(41) "syntax error, unexpected 'FOO' (T_STRING)"
string(46) "syntax error, unexpected identifier (T_STRING)"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75252&edit=1