(critical?) object comparison recursion bug

From: Date: Sun, 29 Sep 2002 11:22:24 +0000
Subject: (critical?) object comparison recursion bug
Groups: php.dev 
Request: Send a blank email to php-dev+get-88734@lists.php.net to get a copy of this message
The code below produces: Fatal error: Nesting level too deep - recursive dependency? in test.php on line 24 This is should not happen since the objects being compared are the same object, so there should be no need to recusively compare the objects. Additionally, I think the comparison should bail out (without a fatal error) when the objects are not the same and when a recursive dependency is found. IMHO, this is a critical problem that should be fixed for 4.3, since it prevents anyone from using OO with references in a reasonable way. <?php class A { var $b; function A() { $this->b =& new B($this); } } class B { var $a; function B(&$a) { $this->a =& $a; } } $one =& new A; $two =& $one; if ($one == $two) { // <-- fatal error here echo "Same object\n"; } else { echo "not the same object\n"; } ?> -- Wez Furlong The Brain Room Ltd.

« previous php.dev (#88734) next »