Req #75218 [NEW]: Change remaining uncatchable fatal errors for parsing into ParseError

From: Date: Mon, 18 Sep 2017 02:41:42 +0000
Subject: Req #75218 [NEW]: Change remaining uncatchable fatal errors for parsing into ParseError
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211198@lists.php.net to get a copy of this message
From: tandre at themeetgroup dot com Operating system: PHP version: 7.2.0RC2 Package: Unknown/Other Function Bug Type: Feature/Change Request Bug description:Change remaining uncatchable fatal errors for parsing into ParseError Description: ------------ Observed behavior: Evaluating, requiring, or even building the syntax tree of certain code snippets results in an uncatchable fatal error (Even if the code wouldn't be executed) Expected behavior: Instead of an uncatchable fatal error, a ParseError (or other Error type, or a new Error subclass) should be thrown. Affected PHP versions: PHP 7.0+, including 7.2.0RC2. Requested fix version: PHP 7.2 (to avoid backwards compatibility breaks) This also affects extensions using the C API to build an abstract syntax tree. See https://github.com/nikic/php-ast/issues/78 4 types of fatal errors are mentioned in the test script. Test script: --------------- function try_eval($code) { try { eval($code); } catch (\Throwable $e) { print("Caught throwable\n"); echo $e; } } // Would output: Fatal error: Multiple final modifiers are not allowed in /path/to/snippet.php(3) : eval()'d code on line 1 (Not catchable) try_eval('if (false) {class C { final final function foo($fff) {}}}'); // Would output: Fatal error: Multiple access type modifiers are not allowed in /path/to/snippet.php(5) : eval()'d code on line 1 (not catchable) try_eval('if (false) {class C { private protected $x; }}'); // Would output: Fatal error: __HALT_COMPILER() can only be used from the outermost scope in /path/to/snippet.php(5) : eval()'d code on line 1 try_eval('if (true) { __HALT_COMPILER(); }'); // Would output: Fatal error: Encoding must be a literal in /path/to/snippet.php(4) : eval()'d code on line 1 (Not catchable) try_eval('declare(encoding=[]);'); Expected result: ---------------- The test script should print "Caught throwable" (and the exception) and proceed to subsequent statements Actual result: -------------- Only one line of output is emitted. The error can't be caught by set_error_handler() or any other means: Fatal error: Multiple final modifiers are not allowed in /path/to/snippet.php(3) : eval()'d code on line 1 -- Edit bug report at https://bugs.php.net/bug.php?id=75218&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75218&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75218&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75218&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75218&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75218&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75218&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75218&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75218&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75218&r=support Expected behavior: https://bugs.php.net/fix.php?id=75218&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75218&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75218&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75218&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75218&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75218&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75218&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75218&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75218&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75218&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75218&r=mysqlcfg

« previous php.bugs (#211198) next »