summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-06-28 18:22:51 +0200
committerNikita Popov <nikic@php.net>2014-06-28 18:24:59 +0200
commite198132542de0be17ba25f10f0b880e721c3f67c (patch)
treee6f54a5e8a25bc4a5aed74ee53201242edcb05a6
parent111ad71d38a62f937cfbf6a49f37b1be43860c81 (diff)
downloadphp-git-e198132542de0be17ba25f10f0b880e721c3f67c.tar.gz
Drop addition of weird \ prefix for FQ consts
Also fixes a resolution bug
-rw-r--r--Zend/tests/use_const/no_global_fallback.phpt3
-rw-r--r--Zend/zend_compile.c9
-rw-r--r--Zend/zend_language_parser.y5
3 files changed, 4 insertions, 13 deletions
diff --git a/Zend/tests/use_const/no_global_fallback.phpt b/Zend/tests/use_const/no_global_fallback.phpt
index a128f353ed..64e2a154ce 100644
--- a/Zend/tests/use_const/no_global_fallback.phpt
+++ b/Zend/tests/use_const/no_global_fallback.phpt
@@ -10,5 +10,4 @@ var_dump(baz);
?>
--EXPECTF--
-Notice: Use of undefined constant baz - assumed 'baz' in %s on line %d
-string(3) "baz"
+Fatal error: Undefined constant 'foo\bar\baz' in %s on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index b9cfb3055a..bf02734e4f 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7404,7 +7404,6 @@ void zend_compile_const(znode *result, zend_ast *ast TSRMLS_DC) {
zend_ast *name_ast = ast->child[0];
zend_bool check_namespace = name_ast->attr;
- zend_bool is_compound = zend_is_compound_name(zend_ast_get_zval(name_ast));
znode name_node;
zend_op *opline;
@@ -7418,8 +7417,7 @@ void zend_compile_const(znode *result, zend_ast *ast TSRMLS_DC) {
opline = emit_op_tmp(result, ZEND_FETCH_CONSTANT, NULL, NULL TSRMLS_CC);
opline->op2_type = IS_CONST;
- if (is_compound) {
- /* the name is unambiguous */
+ if (!check_namespace || zend_is_compound_name(zend_ast_get_zval(name_ast))) {
opline->op2.constant = zend_add_const_name_literal(
CG(active_op_array), &name_node.u.constant, 0 TSRMLS_CC);
} else {
@@ -7610,13 +7608,10 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr TSRMLS_DC) {
zend_ast *ast = *ast_ptr;
zend_ast *const_name_ast = ast->child[0];
zend_bool check_namespace = const_name_ast->attr;
- zend_bool is_compound;
znode const_name, result;
zend_compile_expr(&const_name, const_name_ast TSRMLS_CC);
- is_compound = zend_is_compound_name(&const_name.u.constant);
-
if (zend_constant_ct_subst(&result, &const_name.u.constant, 0 TSRMLS_CC)) {
zend_ast_destroy(ast);
*ast_ptr = zend_ast_create_zval(&result.u.constant);
@@ -7630,7 +7625,7 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr TSRMLS_DC) {
if (IS_INTERNED(Z_STR(result.u.constant))) {
Z_TYPE_FLAGS(result.u.constant) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE);
}
- if (!is_compound) {
+ if (check_namespace && !zend_is_compound_name(zend_ast_get_zval(const_name_ast))) {
Z_CONST_FLAGS(result.u.constant) = IS_CONSTANT_UNQUALIFIED;
}
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 4fed735826..eeffcf610e 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -995,10 +995,7 @@ scalar:
zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC);
$$.u.ast = zend_ast_create_unary(ZEND_AST_CONST, AST_ZVAL(&$1)); }
| T_NS_SEPARATOR namespace_name
- { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRLEN($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1);
- if (Z_DELREF($2.u.constant) == 0) { efree(Z_STR($2.u.constant)); }
- Z_STR($2.u.constant) = Z_STR(tmp);
- $$.u.ast = zend_ast_create_unary(ZEND_AST_CONST, AST_ZVAL(&$2)); }
+ { $$.u.ast = zend_ast_create_unary(ZEND_AST_CONST, AST_ZVAL(&$2)); }
;