[php-src] PR #23397: Fixed GH-22727: Attribute return opcodes to return statement
| From: | joostwaaijer | Date: | Fri, 21 Aug 2026 06:22:57 +0000 |
| Subject: | [php-src] PR #23397: Fixed GH-22727: Attribute return opcodes to return statement | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38033@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23397
Author: joostwaaijer
> [!NOTE]
> This pull request description was prepared with assistance from OpenAI Codex and reviewed by
> the contributor.
>
>
zend_compile_return() currently leaves
> CG(zend_lineno) at the last line compiled inside a multiline return
> expression. As a result, VERIFY_RETURN_TYPE and
> RETURN are attributed to a match arm or ternary branch instead of
> the return statement. Coverage drivers then omit the actual return
> line and may report a different branch line as executed. This is the specific return-expression case
> described in GH-22727 and is part of the broader GH-18985 issue.
>
> This patch captures the statement line before compiling the expression and restores it before
> emitting return-related opcodes. It deliberately avoids the broader expression compiler changes from
> GH-22833 that were reverted.
>
> A PHPT regression test verifies the user-visible TypeError line. The test fails on PHP 8.4.24
> with line 6 instead of line 5, and passes on the patched PHP 8.4.26-dev build.
>
> Validation: debug NTS build with all Zend/tests (4,837 passed,
> 134 skipped, 1 expected failure, 0 failures); debug ZTS build with the focused regression test; and
> PCOV 1.0.12 verification showing the direct return match line
> changes from absent to hit count 1.