Repository navigation
Fixed GH-22727: Attribute return opcodes to return statement - #23397
joostwaaijer wants to merge 2 commits into
Conversation
Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com>
|
So the original fix was rejected by @derickr because it influenced too many things in xdebug. I assume he meant tests. |
|
Quoted below: written with Claude, an LLM, as CONTRIBUTING.md asks us to mark. The builds and test runs behind it are on my machine; the commands to repeat them are under the fold.
|
Note
This pull request description was prepared with assistance from OpenAI Codex and reviewed by the contributor.
zend_compile_return()currently leavesCG(zend_lineno)at the last line compiled inside a multiline return expression. As a result,VERIFY_RETURN_TYPEandRETURNare attributed to a match arm or ternary branch instead of thereturnstatement. 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 directreturn matchline changes from absent to hit count 1.