cvs: ZendEngine2 / zend_compile.c
| From: | Andi Gutmans | Date: | Fri, 10 Sep 2004 06:13:14 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2957@lists.php.net to get a copy of this message | ||
andi Fri Sep 10 02:13:14 2004 EDT
Modified files:
/ZendEngine2 zend_compile.c
Log:
- This one fixes rather strange problem - ZE allows multiple declarations of the same class
constant.
- It could be a minor BC break, but I'm sure it's a bug. (Antony Dovgal aka tony2001)
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.589&r2=1.590&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.589 ZendEngine2/zend_compile.c:1.590
--- ZendEngine2/zend_compile.c:1.589 Thu Sep 9 12:51:45 2004
+++ ZendEngine2/zend_compile.c Fri Sep 10 02:13:13 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.589 2004/09/09 16:51:45 andi Exp $ */
+/* $Id: zend_compile.c,v 1.590 2004/09/10 06:13:13 andi Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -2641,7 +2641,7 @@
void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC)
{
zval *property;
-
+
if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
zend_error(E_COMPILE_ERROR, "Arrays are not allowed in class constants");
}
@@ -2655,8 +2655,10 @@
property->type = IS_NULL;
}
- zend_hash_update(&CG(active_class_entry)->constants_table,
var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property,
sizeof(zval *), NULL);
-
+ if (zend_hash_add(&CG(active_class_entry)->constants_table,
var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property,
sizeof(zval *), NULL)==FAILURE) {
+ FREE_ZVAL(property);
+ zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s",
CG(active_class_entry)->name, var_name->u.constant.value.str.val);
+ }
FREE_PNODE(var_name);
}