Skip to content

Derive expression-statement exit points from the never type - #6150

Merged
ondrejmirtes merged 1 commit into
2.2.xfrom
exit-points-from-never
Jul 30, 2026
Merged

Derive expression-statement exit points from the never type#6150
ondrejmirtes merged 1 commit into
2.2.xfrom
exit-points-from-never

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Extracted from the resolve-type-rewrite-2 branch: findEarlyTerminatingExpr() is deleted - its Exit_/Throw_ special cases price as explicit NeverType themselves (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 phpstan and make cs green; zero analysis-output churn (incl. bug-4734 integration coverage).

🤖 Generated with Claude Code

https://claude.ai/code/session_01DaBZjgksga4c5s6Q9FniY7

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
@ondrejmirtes
ondrejmirtes merged commit 9da79ba into 2.2.x Jul 30, 2026
741 of 745 checks passed
@ondrejmirtes
ondrejmirtes deleted the exit-points-from-never branch July 30, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant