Commit fde23dffbcb for php.net
commit fde23dffbcb15b2d82d00d11470f1d000ce446ec
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date: Wed Aug 12 15:37:02 2026 +0200
Revert lineno changes
Partially reverts:
- 07d308a0debc1219d4ef4b789d6a46ec4fb740d3
- 7ad79be6550fba20df3d7cea0a5d9da79861c1f9
We'll solve this in a different way.
diff --git a/NEWS b/NEWS
index e569af4b6a0..fa2bc69c39f 100644
--- a/NEWS
+++ b/NEWS
@@ -192,8 +192,6 @@ PHP NEWS
. Implemented partial function application RFC. (Arnaud)
. Fixed bug GH-22263 (reset typed property default on every unserialize
failure path). (David Carlier)
- . Fixed bug GH-18985 (Wrong line numbers for match with constant arms).
- (ilutov)
. Fixed bug GH-18847 (SEGV in zend_fetch_debug_backtrace() when the memory
limit is reached while the tracing JIT enters a call frame). (Arnaud,
iliaal)
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 1d837c59832..91822e88668 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7165,8 +7165,6 @@ static void zend_compile_match(znode *result, zend_ast *ast)
zend_ast *arm_ast = arms->child[i];
zend_ast *body_ast = arm_ast->child[1];
- CG(zend_lineno) = zend_ast_get_lineno(arm_ast);
-
if (arm_ast->child[0] != NULL) {
zend_ast_list *conds = zend_ast_get_list(arm_ast->child[0]);
@@ -10787,8 +10785,6 @@ static void zend_compile_binary_op(znode *result, zend_ast *ast) /* {{{ */
zend_compile_expr(&left_node, left_ast);
zend_compile_expr(&right_node, right_ast);
- CG(zend_lineno) = ast->lineno;
-
if (left_node.op_type == IS_CONST && right_node.op_type == IS_CONST) {
if (zend_try_ct_eval_binary_op(&result->u.constant, opcode,
&left_node.u.constant, &right_node.u.constant)
@@ -12290,7 +12286,7 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */
return;
}
- CG(zend_lineno) = zend_ast_get_lineno(ast);
+ CG(zend_lineno) = ast->lineno;
if ((CG(compiler_options) & ZEND_COMPILE_EXTENDED_STMT) && !zend_is_unticked_stmt(ast)) {
zend_do_extended_stmt(NULL);
@@ -12414,6 +12410,9 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */
static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
{
+ /* CG(zend_lineno) = ast->lineno; */
+ CG(zend_lineno) = zend_ast_get_lineno(ast);
+
if (CG(memoize_mode) != ZEND_MEMOIZE_NONE) {
zend_compile_memoized_expr(result, ast, BP_VAR_R);
return;
@@ -12555,9 +12554,6 @@ static void zend_compile_expr(znode *result, zend_ast *ast)
{
zend_check_stack_limit();
- uint32_t prev_lineno = CG(zend_lineno);
- CG(zend_lineno) = zend_ast_get_lineno(ast);
-
uint32_t checkpoint = zend_short_circuiting_checkpoint();
zend_compile_expr_inner(result, ast);
zend_short_circuiting_commit(checkpoint, result, ast);
@@ -12567,12 +12563,12 @@ static void zend_compile_expr(znode *result, zend_ast *ast)
ZEND_ASSERT(result->op_type != IS_VAR);
}
#endif
-
- CG(zend_lineno) = prev_lineno;
}
static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t type, bool by_ref)
{
+ CG(zend_lineno) = zend_ast_get_lineno(ast);
+
if (CG(memoize_mode) != ZEND_MEMOIZE_NONE) {
switch (ast->kind) {
case ZEND_AST_CALL:
@@ -12633,9 +12629,6 @@ static zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, bo
{
zend_check_stack_limit();
- uint32_t prev_lineno = CG(zend_lineno);
- CG(zend_lineno) = zend_ast_get_lineno(ast);
-
uint32_t checkpoint = zend_short_circuiting_checkpoint();
zend_op *opcode = zend_compile_var_inner(result, ast, type, by_ref);
zend_short_circuiting_commit(checkpoint, result, ast);
@@ -12649,9 +12642,6 @@ static zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, bo
ZEND_ASSERT(result->op_type != IS_VAR);
}
#endif
-
- CG(zend_lineno) = prev_lineno;
-
return opcode;
}
@@ -12659,37 +12649,25 @@ static zend_op *zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t
{
zend_check_stack_limit();
- uint32_t prev_lineno = CG(zend_lineno);
- CG(zend_lineno) = zend_ast_get_lineno(ast);
-
- zend_op *opline;
switch (ast->kind) {
case ZEND_AST_VAR:
- opline = zend_compile_simple_var(result, ast, type, true);
- break;
+ return zend_compile_simple_var(result, ast, type, true);
case ZEND_AST_DIM:
- opline = zend_delayed_compile_dim(result, ast, type, by_ref);
- break;
+ return zend_delayed_compile_dim(result, ast, type, by_ref);
case ZEND_AST_PROP:
case ZEND_AST_NULLSAFE_PROP:
{
- opline = zend_delayed_compile_prop(result, ast, type);
+ zend_op *opline = zend_delayed_compile_prop(result, ast, type);
if (by_ref) {
opline->extended_value |= ZEND_FETCH_REF;
}
- break;
+ return opline;
}
case ZEND_AST_STATIC_PROP:
- opline = zend_compile_static_prop(result, ast, type, by_ref, true);
- break;
+ return zend_compile_static_prop(result, ast, type, by_ref, true);
default:
- opline = zend_compile_var(result, ast, type, false);
- break;
+ return zend_compile_var(result, ast, type, false);
}
-
- CG(zend_lineno) = prev_lineno;
-
- return opline;
}
/* }}} */
diff --git a/ext/opcache/tests/gh18985.phpt b/ext/opcache/tests/gh18985.phpt
index 22c7783cf77..754a0b7dac2 100644
--- a/ext/opcache/tests/gh18985.phpt
+++ b/ext/opcache/tests/gh18985.phpt
@@ -2,6 +2,8 @@
GH-18985: Wrong lineno for multiline expressions
--EXTENSIONS--
opcache
+--XFAIL--
+GH-22833 was reverted, so this will need a different fix.
--INI--
opcache.enable_cli=1
opcache.opt_debug_level=0x40010000
diff --git a/ext/opcache/tests/jit/shift_right_004.phpt b/ext/opcache/tests/jit/shift_right_004.phpt
index 5b816893c53..df65b747ca4 100644
--- a/ext/opcache/tests/jit/shift_right_004.phpt
+++ b/ext/opcache/tests/jit/shift_right_004.phpt
@@ -30,9 +30,9 @@ function test() {
Deprecated: Implicit conversion from float %f to int loses precision in %sshift_right_004.php on line 8
-Warning: A non-numeric value encountered in %sshift_right_004.php on line 6
+Warning: A non-numeric value encountered in %sshift_right_004.php on line 7
-Warning: A non-numeric value encountered in %sshift_right_004.php on line 6
+Warning: A non-numeric value encountered in %sshift_right_004.php on line 7
Fatal error: Uncaught ArithmeticError: Bit shift by negative number in %sshift_right_004.php:8
Stack trace:
diff --git a/ext/opcache/tests/jit/switch_001.phpt b/ext/opcache/tests/jit/switch_001.phpt
index 898ebb363f2..57ee3a40b84 100644
--- a/ext/opcache/tests/jit/switch_001.phpt
+++ b/ext/opcache/tests/jit/switch_001.phpt
@@ -16,7 +16,7 @@ function foo() {
?>
DONE
--EXPECTF--
-Warning: Undefined variable $y in %sswitch_001.php on line 3
+Warning: Undefined variable $y in %sswitch_001.php on line 4
-Warning: Undefined variable $y in %sswitch_001.php on line 3
+Warning: Undefined variable $y in %sswitch_001.php on line 5
DONE