mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix lineno in function redeclaration error
This commit is contained in:
commit
381e020edb
5 changed files with 24 additions and 3 deletions
2
NEWS
2
NEWS
|
@ -15,6 +15,8 @@ PHP NEWS
|
||||||
. Fixed bug GH-16371 (Assertion failure in Zend/zend_weakrefs.c:646). (Arnaud)
|
. Fixed bug GH-16371 (Assertion failure in Zend/zend_weakrefs.c:646). (Arnaud)
|
||||||
. Fixed bug GH-16515 (Incorrect propagation of ZEND_ACC_RETURN_REFERENCE for
|
. Fixed bug GH-16515 (Incorrect propagation of ZEND_ACC_RETURN_REFERENCE for
|
||||||
call trampoline). (ilutov)
|
call trampoline). (ilutov)
|
||||||
|
. Fixed bug GH-16509 (Incorrect line number in function redeclaration error).
|
||||||
|
(ilutov)
|
||||||
|
|
||||||
- Curl:
|
- Curl:
|
||||||
. Fixed bug GH-16302 (CurlMultiHandle holds a reference to CurlHandle if
|
. Fixed bug GH-16302 (CurlMultiHandle holds a reference to CurlHandle if
|
||||||
|
|
7
Zend/tests/gh16509.inc
Normal file
7
Zend/tests/gh16509.inc
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
|
||||||
|
|
||||||
|
echo 'foo';
|
||||||
|
}
|
11
Zend/tests/gh16509.phpt
Normal file
11
Zend/tests/gh16509.phpt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
--TEST--
|
||||||
|
GH-16509: Incorrect lineno reported for function redeclaration
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include __DIR__ . '/gh16509.inc';
|
||||||
|
include __DIR__ . '/gh16509.inc';
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Fatal error: Cannot redeclare test() (previously declared in %sgh16509.inc:3) in %sgh16509.inc on line 3
|
|
@ -1202,7 +1202,7 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen
|
||||||
zend_error_noreturn(error_level, "Cannot redeclare %s() (previously declared in %s:%d)",
|
zend_error_noreturn(error_level, "Cannot redeclare %s() (previously declared in %s:%d)",
|
||||||
op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name),
|
op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name),
|
||||||
ZSTR_VAL(old_function->op_array.filename),
|
ZSTR_VAL(old_function->op_array.filename),
|
||||||
old_function->op_array.opcodes[0].lineno);
|
old_function->op_array.line_start);
|
||||||
} else {
|
} else {
|
||||||
zend_error_noreturn(error_level, "Cannot redeclare %s()",
|
zend_error_noreturn(error_level, "Cannot redeclare %s()",
|
||||||
op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name));
|
op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name));
|
||||||
|
@ -7684,6 +7684,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
|
||||||
} else if (toplevel) {
|
} else if (toplevel) {
|
||||||
/* Only register the function after a successful compile */
|
/* Only register the function after a successful compile */
|
||||||
if (UNEXPECTED(zend_hash_add_ptr(CG(function_table), lcname, op_array) == NULL)) {
|
if (UNEXPECTED(zend_hash_add_ptr(CG(function_table), lcname, op_array) == NULL)) {
|
||||||
|
CG(zend_lineno) = decl->start_lineno;
|
||||||
do_bind_function_error(lcname, op_array, true);
|
do_bind_function_error(lcname, op_array, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,13 +175,13 @@ failure:
|
||||||
function2 = Z_PTR_P(t);
|
function2 = Z_PTR_P(t);
|
||||||
CG(in_compilation) = 1;
|
CG(in_compilation) = 1;
|
||||||
zend_set_compiled_filename(function1->op_array.filename);
|
zend_set_compiled_filename(function1->op_array.filename);
|
||||||
CG(zend_lineno) = function1->op_array.opcodes[0].lineno;
|
CG(zend_lineno) = function1->op_array.line_start;
|
||||||
if (function2->type == ZEND_USER_FUNCTION
|
if (function2->type == ZEND_USER_FUNCTION
|
||||||
&& function2->op_array.last > 0) {
|
&& function2->op_array.last > 0) {
|
||||||
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
|
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
|
||||||
ZSTR_VAL(function1->common.function_name),
|
ZSTR_VAL(function1->common.function_name),
|
||||||
ZSTR_VAL(function2->op_array.filename),
|
ZSTR_VAL(function2->op_array.filename),
|
||||||
(int)function2->op_array.opcodes[0].lineno);
|
(int)function2->op_array.line_start);
|
||||||
} else {
|
} else {
|
||||||
zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
|
zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue