Fixed GH-22727: Attribute return opcodes to return statement - #23397
Open
joostwaaijer wants to merge 1 commit into
Open
Fixed GH-22727: Attribute return opcodes to return statement#23397joostwaaijer wants to merge 1 commit into
joostwaaijer wants to merge 1 commit into
Conversation
joostwaaijer
marked this pull request as ready for review
August 21, 2026 06:35
NickSdot
reviewed
Aug 21, 2026
Comment on lines
+15
to
+21
| } catch (TypeError $exception) { | ||
| echo $exception->getLine(), "\n"; | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECT-- | ||
| 5 |
Contributor
There was a problem hiding this comment.
Suggested change
| } catch (TypeError $exception) { | |
| echo $exception->getLine(), "\n"; | |
| } | |
| ?> | |
| --EXPECT-- | |
| 5 | |
| } catch (Throwable $e) { | |
| echo $e::class, ': on line ', $e->getLine(), "\n"; | |
| } | |
| ?> | |
| --EXPECT-- | |
| TypeError: on line 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.