Skip to content

Move list-contradiction NeverType out of unsetOffset into tryRemove#5707

Merged
ondrejmirtes merged 1 commit into
2.1.xfrom
unsetoffset-cleanup
May 19, 2026
Merged

Move list-contradiction NeverType out of unsetOffset into tryRemove#5707
ondrejmirtes merged 1 commit into
2.1.xfrom
unsetoffset-cleanup

Conversation

@ondrejmirtes
Copy link
Copy Markdown
Member

Summary

  • unsetOffset is a "what does this array look like after unsetting X?" operation — its result should always still be an array.
  • The three identical elseif ($this->isList->yes() && $newIsList->no()) { return new NeverType(); } returns inside unsetOffset were subtraction semantics leaking up from the only two callers that pass preserveListCertainty = true: the HasOffsetType and HasOffsetValueType arms of tryRemove.
  • Pushed the check up into tryRemove, where it correctly expresses "definitely-a-list minus a definitely-present key = empty set". unsetOffset now consistently returns the post-unset shape across all three of its branches.

Behaviour is preserved — full test suite green.

Test plan

  • make tests — 12,156 tests pass

🤖 Generated with Claude Code

…ove`

`unsetOffset` is a "what does this array look like after unsetting X?"
operation — its result is always still an array. The three identical
`elseif ($this->isList->yes() && $newIsList->no()) { return new NeverType(); }`
returns sprinkled through the three branches were subtraction semantics
leaking up from the only two callers that pass
`preserveListCertainty = true`: the `HasOffsetType` and `HasOffsetValueType`
arms of `tryRemove`.

Push that check up to its actual home in `tryRemove`. The unset branches
now consistently return the post-unset shape; `tryRemove` decides on its
own that "definitely-a-list minus a definitely-present key = empty set"
and returns `NeverType` for that one case. Behaviour is preserved (full
test suite green).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ondrejmirtes ondrejmirtes merged commit 7e842cf into 2.1.x May 19, 2026
654 of 656 checks passed
@ondrejmirtes ondrejmirtes deleted the unsetoffset-cleanup branch May 19, 2026 09:32
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