cvs: ZendEngine2(PHP_5_3) / zend_compile.c /tests bug42859.phpt ns_029.phpt ns_030.phpt
| From: | Dmitry Stogov | Date: | Mon, 12 Nov 2007 17:52:15 +0000 |
| Subject: | cvs: ZendEngine2(PHP_5_3) / zend_compile.c /tests bug42859.phpt ns_029.phpt ns_030.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-6159@lists.php.net to get a copy of this message | ||
dmitry Mon Nov 12 17:52:15 2007 UTC
Modified files: (Branch: PHP_5_3)
/ZendEngine2 zend_compile.c
/ZendEngine2/tests bug42859.phpt ns_029.phpt ns_030.phpt
Log:
better error messages
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.19&r2=1.647.2.27.2.41.2.20&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.19
ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.20
--- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.19 Mon Nov 12 16:55:44 2007
+++ ZendEngine2/zend_compile.c Mon Nov 12 17:52:15 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.19 2007/11/12 16:55:44 tony2001 Exp $ */
+/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.20 2007/11/12 17:52:15 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -3019,7 +3019,7 @@
if (Z_STRLEN_PP(ns_name) != Z_STRLEN(class_name->u.constant) ||
memcmp(tmp, lcname, Z_STRLEN(class_name->u.constant))) {
- zend_error(E_COMPILE_ERROR, "Class name '%s' conflicts with import name",
Z_STRVAL(class_name->u.constant));
+ zend_error(E_COMPILE_ERROR, "Cannot declare class %s because the name is already in
use", Z_STRVAL(class_name->u.constant));
}
efree(tmp);
}
@@ -4660,7 +4660,7 @@
!memcmp(lcname, "self", sizeof("self")-1)) ||
((Z_STRLEN_P(name) == sizeof("parent")-1) &&
!memcmp(lcname, "parent", sizeof("parent")-1))) {
- zend_error(E_COMPILE_ERROR, "Cannot use '%s' as import name",
Z_STRVAL_P(name));
+ zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because '%s' is a special class
name", Z_STRVAL_P(ns), Z_STRVAL_P(name), Z_STRVAL_P(name));
}
if (CG(current_namespace)) {
@@ -4676,7 +4676,7 @@
if (Z_STRLEN_P(ns) != Z_STRLEN_P(CG(current_namespace)) + 2 + Z_STRLEN_P(name) ||
memcmp(tmp, ns_name, Z_STRLEN_P(ns))) {
- zend_error(E_COMPILE_ERROR, "Import name '%s' conflicts with defined
class", Z_STRVAL_P(name));
+ zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use",
Z_STRVAL_P(ns), Z_STRVAL_P(name));
}
efree(tmp);
}
@@ -4686,13 +4686,13 @@
if (Z_STRLEN_P(ns) != Z_STRLEN_P(name) ||
memcmp(tmp, lcname, Z_STRLEN_P(ns))) {
- zend_error(E_COMPILE_ERROR, "Import name '%s' conflicts with defined class",
Z_STRVAL_P(name));
+ zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use",
Z_STRVAL_P(ns), Z_STRVAL_P(name));
}
efree(tmp);
}
if (zend_hash_add(CG(current_import), lcname, Z_STRLEN_P(name)+1, &ns, sizeof(zval*), NULL) !=
SUCCESS) {
- zend_error(E_COMPILE_ERROR, "Cannot reuse import name");
+ zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use",
Z_STRVAL_P(ns), Z_STRVAL_P(name));
}
if (warn) {
zend_error(E_WARNING, "The use statement with non-compound name '%s' has no
effect", Z_STRVAL_P(name));
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug42859.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: ZendEngine2/tests/bug42859.phpt
diff -u ZendEngine2/tests/bug42859.phpt:1.1.2.2 ZendEngine2/tests/bug42859.phpt:1.1.2.3
--- ZendEngine2/tests/bug42859.phpt:1.1.2.2 Wed Nov 7 09:09:21 2007
+++ ZendEngine2/tests/bug42859.phpt Mon Nov 12 17:52:15 2007
@@ -9,4 +9,4 @@
use Blah::Ex;
?>
--EXPECTF--
-Fatal error: Import name 'Ex' conflicts with defined class in %sbug42859.php on line 6
\ No newline at end of file
+Fatal error: Cannot use Blah::Ex as Ex because the name is already in use in %sbug42859.php on line
6
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_029.phpt?r1=1.2.2.3&r2=1.2.2.4&diff_format=u
Index: ZendEngine2/tests/ns_029.phpt
diff -u ZendEngine2/tests/ns_029.phpt:1.2.2.3 ZendEngine2/tests/ns_029.phpt:1.2.2.4
--- ZendEngine2/tests/ns_029.phpt:1.2.2.3 Wed Nov 7 09:09:21 2007
+++ ZendEngine2/tests/ns_029.phpt Mon Nov 12 17:52:15 2007
@@ -1,12 +1,12 @@
---TEST--
-029: Name ambiguity (class name & import name)
---FILE--
-<?php
-use A::B as Foo;
-
-class Foo {
-}
-
-new Foo();
---EXPECTF--
-Fatal error: Class name 'Foo' conflicts with import name in %sns_029.php on line 4
+--TEST--
+029: Name ambiguity (class name & import name)
+--FILE--
+<?php
+use A::B as Foo;
+
+class Foo {
+}
+
+new Foo();
+--EXPECTF--
+Fatal error: Cannot declare class Foo because the name is already in use in %sns_029.php on line 4
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_030.phpt?r1=1.2.2.3&r2=1.2.2.4&diff_format=u
Index: ZendEngine2/tests/ns_030.phpt
diff -u ZendEngine2/tests/ns_030.phpt:1.2.2.3 ZendEngine2/tests/ns_030.phpt:1.2.2.4
--- ZendEngine2/tests/ns_030.phpt:1.2.2.3 Wed Nov 7 09:09:21 2007
+++ ZendEngine2/tests/ns_030.phpt Mon Nov 12 17:52:15 2007
@@ -9,4 +9,4 @@
new Foo();
--EXPECTF--
-Fatal error: Import name 'Foo' conflicts with defined class in %sns_030.php on line 5
+Fatal error: Cannot use A::B as Foo because the name is already in use in %sns_030.php on line 5