Derive expression-statement exit points from the never type - #6150
Merged
Conversation
findEarlyTerminatingExpr() special-cased Exit_/Throw_ and otherwise read the statement expression's type - exit/die/throw price as explicit never themselves, so the type check covers all of it. The read stays on the pre-statement scope: a conditional return type must resolve against the argument types the call was made with, not against state the statement itself just changed (bug-11565's list-reassignment). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7
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.
Extracted from the resolve-type-rewrite-2 branch:
findEarlyTerminatingExpr()is deleted - itsExit_/Throw_special cases price as explicitNeverTypethemselves (and early-terminating call configs already resolve to never through the call handlers since #6134), so the expression statement's exit point comes from one explicit-never check on the statement expression's type.The read stays on the pre-statement scope: a conditional return type must resolve against the argument types the call was made with, not against state the statement itself just changed —
bug-11565.php's$items = iteratorToList($items)would otherwise re-resolve($iterable is list ? never : list<T>)against the freshly assigned list and mark everything after it dead.Full test suite,
make phpstanandmake csgreen; zero analysis-output churn (incl. bug-4734 integration coverage).🤖 Generated with Claude Code
https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7