Skip to content

Commit 5e998dd

Browse files
committed
Set lineno of RECV[_INIT] ops to function start
Restores behavior prior to GH-19100.
1 parent ea9a7b2 commit 5e998dd

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Zend/tests/recv_lineno_001.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
RECV[_INIT] lineno is function start
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public function __construct(
8+
public $x = FOO,
9+
) {}
10+
}
11+
12+
new Foo();
13+
14+
?>
15+
--EXPECTF--
16+
Fatal error: Uncaught Error: Undefined constant "FOO" in %s:4
17+
Stack trace:
18+
#0 %s(9): Foo->__construct()
19+
#1 {main}
20+
thrown in %s on line 4

Zend/zend_compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7639,7 +7639,7 @@ static bool zend_property_is_virtual(zend_class_entry *ce, zend_string *property
76397639
return is_virtual;
76407640
}
76417641

7642-
static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fallback_return_type) /* {{{ */
7642+
static void zend_compile_params(zend_ast_decl *func_decl_ast, zend_ast *ast, zend_ast *return_type_ast, uint32_t fallback_return_type) /* {{{ */
76437643
{
76447644
zend_ast_list *list = zend_ast_get_list(ast);
76457645
uint32_t i;
@@ -7817,6 +7817,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
78177817
opline = zend_emit_op(NULL, opcode, NULL, &default_node);
78187818
SET_NODE(opline->result, &var_node);
78197819
opline->op1.num = i + 1;
7820+
opline->lineno = func_decl_ast->start_lineno;
78207821

78217822
uint32_t arg_info_flags = _ZEND_ARG_INFO_FLAGS(is_ref, is_variadic, /* is_tentative */ 0)
78227823
| (is_promoted ? _ZEND_IS_PROMOTED_BIT : 0);
@@ -8457,7 +8458,7 @@ static zend_op_array *zend_compile_func_decl_ex(
84578458
zend_stack_push(&CG(loop_var_stack), (void *) &dummy_var);
84588459
}
84598460

8460-
zend_compile_params(params_ast, return_type_ast,
8461+
zend_compile_params(decl, params_ast, return_type_ast,
84618462
is_method && zend_string_equals_literal(lcname, ZEND_TOSTRING_FUNC_NAME) ? IS_STRING : 0);
84628463
if (CG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) {
84638464
zend_mark_function_as_generator();

0 commit comments

Comments
 (0)