#28290 [Com]: Throwing exception in eval'led code is not handled correctly

From: Date: Thu, 08 Oct 2009 12:41:51 +0000
Subject: #28290 [Com]: Throwing exception in eval'led code is not handled correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143383@lists.php.net to get a copy of this message
ID: 28290 Comment by: cedric at conseil-creation dot com Reported By: arnoud at rattink dot com Status: No Feedback Bug Type: Scripting Engine problem Operating System: SuSE Linux 8.2 PHP Version: 5.0.0RC2 New Comment: Don't think it's a bug... just read the following not in PHP.NET eval manual: "If there is a parse error in the evaluated code, eval() returns FALSE and execution of the following code continues normally." What about this code (?!): --------------------------- if ( eval('$f = AAAAAARRRRRRG();') ) { echo "GRRRRRRRR\n"; } --------------------------- Or this one: --------------------------- if ( !eval('$f = AAAAAARRRRRRG();') ) { // parse error } echo "GRRRRRRRR\n"; } --------------------------- Previous Comments: ------------------------------------------------------------------------ [2005-01-22 01:00:04] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2005-01-15 00:23:42] tony2001@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.0-win32-latest.zip Can't reproduce, seems to be fixed. ------------------------------------------------------------------------ [2004-05-14 00:01:42] arnoud at rattink dot com That is not true. Example: <? function f() { throw new Exception("I am an exception"); } try { $v = f(); echo "This is not supposed to get printed\n"; } catch(Exception $e) { echo "caught exception\n"; } ?> This just prints 'caught exception'. That is entirely correct. Now if you were right, then the above code should execute both echos. It does not, so is that a bug? I say it's a catch 22. Either this program, or the one with the 'eval' works out wrong. Personally I believe the whole idea of 'throwing an exception' is that you bypass all intermediate code and land straight into the 'catch' block. At least, that's how it works in C++ and Java. ------------------------------------------------------------------------ [2004-05-11 05:10:37] vkatragadda at email dot com hello, i dont think this is a bug. i believe the line after eval gets executed by default. i think everything in the try{} block is supposed to get executed, and then the catch{} block is called... ------------------------------------------------------------------------ [2004-05-11 05:07:44] vkatragadda at email dot com hello, i dont think this is a bug. i believe the line after eval gets executed by default. i think everything in the try{} block is supposed to get executed, and then the catch{} block is called... ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/28290 -- Edit this bug report at http://bugs.php.net/?id=28290&edit=1

« previous php.bugs (#143383) next »