#18526 [Opn->Bgs]: assertion fails

From: Date: Wed, 11 Sep 2002 19:05:04 +0000
Subject: #18526 [Opn->Bgs]: assertion fails
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-19185@lists.php.net to get a copy of this message
ID: 18526 Updated by: iliaa@php.net Reported By: horny@mail.az -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Windows XP PHP Version: 4.2.1 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php !is_null($freeflag) returns FALSE, which is why your assertaion is returning a warning. Previous Comments: ------------------------------------------------------------------------ [2002-07-30 01:16:16] horny@mail.az This is my bug. $retval = (bool) rand() % 2; should of course be $retval = (bool) (rand() % 2); But in the real code (off of which I made up this example) the assertion still fails mysteriously... ------------------------------------------------------------------------ [2002-07-24 02:58:19] horny@mail.az <?php assert_options(ASSERT_ACTIVE, '1'); assert_options(ASSERT_WARNING, '1'); assert_options(ASSERT_QUIET_EVAL, '0'); $AVAILABLE_LANGS = array('az' => 'az', 'ru' => 'ru', 'en' => 'en'); # as per RFC 1766 function func($predicate) { do { $freeflag = null; if (call_user_func($predicate, $freeflag) === FALSE) break; assert('!is_null($freeflag)'); } while (0); } class foo { function foo_method(&$freeflag) { $retval = (bool) rand() % 2; if ($retval) $freeflag = 1; return $retval; } } $foo_instance = new foo; func(array($foo_instance, 'foo_method')); ?> D:\>c:\php\php-cli haha.php Warning: Assertion "!is_null($freeflag)" failed in haha.php on line 14 It occurs *always* no matter what foo_method() returns, as if asserts() are happening asynchronously. If I instead change func() to function func($predicate) { $freeflag = null; if (call_user_func($predicate, $freeflag) === TRUE) assert('!is_null($freeflag)'); } The assertion doesn't fail. (because it's NOTREACHED?) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18526&edit=1

« previous php.bugs (#19185) next »