Skip to content

Commit 4340c57

Browse files
committed
MFZE1
1 parent 9037bed commit 4340c57

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Zend/zend_compile.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,18 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
11491149
zend_hash_find(function_table, opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len, (void *) &function);
11501150
if (zend_hash_add(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, function, sizeof(zend_function), NULL)==FAILURE) {
11511151
int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR;
1152-
1153-
zend_error(error_level, "Cannot redeclare %s()", opline->op2.u.constant.value.str.val);
1152+
zend_function *function;
1153+
1154+
if (zend_hash_find(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void *) &function)==SUCCESS
1155+
&& function->type==ZEND_USER_FUNCTION
1156+
&& ((zend_op_array *) function)->last>0) {
1157+
zend_error(error_level, "Cannot redeclare %s() (previously declared in %s:%d)",
1158+
opline->op2.u.constant.value.str.val,
1159+
((zend_op_array *) function)->filename,
1160+
((zend_op_array *) function)->opcodes[0].lineno);
1161+
} else {
1162+
zend_error(error_level, "Cannot redeclare %s()", opline->op2.u.constant.value.str.val);
1163+
}
11541164
return FAILURE;
11551165
} else {
11561166
(*function->op_array.refcount)++;

0 commit comments

Comments
 (0)