Edit report at http://bugs.php.net/bug.php?id=53528&edit=1
ID: 53528 User updated by: php at dynamicplus dot it Reported by: php at dynamicplus dot it Summary: eval is not correctly catching parse error Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: CORRECT FATAL ERROR... <?php return 1; // exits here fatalUndefinedFunction(); ?> macbook-air:~ dynamicplus$ php -l lint-test1.php No syntax errors detected in lint-test1.php macbook-air:~ dynamicplus$ php lint-test1.php Fatal error: Call to undefined function fatalUndefinedFunction() in /Users/dynamicplus/lint-test1.php on line 3 ------ WRONG FATAL ERROR.... <?php return TRUE; // dies completely? wrongAssigment() = FALSE; ?> macbook-air:~ dynamicplus$ php lint-test1.php Fatal error: Can't use function return value in write context in /Users/dynamicplus/lint-test1.php on line 4 macbook-air:~ dynamicplus$ php -l lint-test1.php Fatal error: Can't use function return value in write context in lint-test1.php on line 4 Errors parsing lint-test1.php LINT is telling is a PARSE ERROR... LINT SHOULD not execute code but only check syntax, or not? Previous Comments: ------------------------------------------------------------------------ [2010-12-13 10:08:27] [email protected] That's a runtime fatal error, not a parse error, and hence results in the script execution halting, as per the second note on the eval() manual page. ------------------------------------------------------------------------ [2010-12-12 18:30:41] php at dynamicplus dot it Description: ------------ --- >From manual page: http://www.php.net/function.eval#Return Values --- eval() shoud return FALSE in case of parse error. In this example crashes completely with a fatal error, executing a dead portion of code. A return should terminate the eval script as soon as is encountered. Seems to be a compilation problem. Test script: --------------- <?php $return = eval( 'return TRUE; /* should never come here */ WrongAssignment() = 1234;' ); ?> Expected result: ---------------- $return should be FALSE as there is a PARSE ERROR (from manual: "If there is a parse error in the evaluated code, eval() returns FALSE and execution of the following code continues normally."). But the parse error is not detected and in this case $return should be TRUE, as the first block simply returns TRUE and the rest is dead-code. Actual result: -------------- Fatal error: Can't use function return value in write context in /Users/dynamicplus/eval-demo.php(3) : eval()'d code on line 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53528&edit=1
