diff --git a/NEWS b/NEWS index 8969cb4ae72..dd28760928e 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ PHP NEWS . Implement GH-10024 (support linting multiple files at once using php -l). (nielsdos) +- Core: + . Fixed line number of JMP instruction over else block. (ilutov) + 06 Jul 2023, PHP 8.3.0alpha3 - Core: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 592e4ca4560..ea71e075f8c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5567,6 +5567,9 @@ static void zend_compile_if(zend_ast *ast) /* {{{ */ zend_compile_stmt(stmt_ast); if (i != list->children - 1) { + /* Set the lineno of JMP to the position of the if keyword, as we don't want to + * report the last line in the if branch as covered if it hasn't actually executed. */ + CG(zend_lineno) = elem_ast->lineno; jmp_opnums[i] = zend_emit_jump(0); } zend_update_jump_target_to_next(opnum_jmpz);