From d85662d6cc2c6d5f69403f6fb2001ff78e1bd174 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 2 Sep 2025 15:03:47 +0100 Subject: [PATCH] Improve accuracy of ext_stmt emits during pipe operations We need to emit the EXT_STMT opcode before we compile the call, so that we attach the line number of where the right hand pipe operator starts. We also do not need to reset the line number anymore. The following code shows where these EXT_STMTs are introduced. ``` "; $result = /* EXT_STMT */ $myString |> /* EXT_STMT(!0:$myString) */ \htmlentities(...) |> /* EXT_STMT($4) */ \str_split(...) |> /* EXT_STMT($6) */ (fn($x) => array_map(strtoupper(...), $x)) |> /* EXT_STMT($9) */ (fn($x) => join( ', ', $x)); /* EXT_STMT */ echo $result, /* EXT_STMT */ "\n"; ``` --- Zend/zend_compile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index e01b985b6d68f..18a1527efe105 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6534,9 +6534,9 @@ static void zend_compile_pipe(znode *result, zend_ast *ast) callable_ast, arg_list_ast); } + zend_do_extended_stmt(&operand_result); + zend_compile_expr(result, fcall_ast); - CG(zend_lineno) = fcall_ast->lineno; - zend_do_extended_stmt(result); } static void zend_compile_match(znode *result, zend_ast *ast)