Fix array_reduce([...], fn, []) enum identity + initial [] ARG_SEND (#5626) - #20012
Merged
Merged
Conversation
Collect the input Array_ when a Closure sits between it and an inline initial [], and bind each Array_ ARG_SEND to its INIT_ARRAY ordinal so enum-case collect-into-[] preserves objects like Zend. Co-authored-by: Cursor <cursoragent@cursor.com>
2 tasks
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.
Summary
array_reduce([E::A, E::B], fn ($c, $i) => …, [])so the inline initial[]is not wired to the enum inputINIT_ARRAY(ARG_SEND was$8,$9,$8instead of$8,$9,$10).Array_when a Closure sits between it and a trailing initialArray_inprecedingInlineCallArgProducersBeforeCfgOp.matchInlineCallArgProducerforarray_reducesibling Array_ ARG_SEND resolution (avoidsmatchInlineArrayProducersToArrayCallArgsbinding the sole array-typed dead temp to the first Array_).test/compliance/cases/stdlib/array_reduce_enum.phpt+test/repro/issue_5626_array_reduce_enum.php.php-src:
ext/standard/array.c—php_array_reduce. PHP implementation:lib/Compiler.phpcall-arg hoist/ARG_SEND (VMext/standard/array_reduce.phpalready preserved enum objects once args were correct).Trust gates (pre-work)
docker info: OKbootstrap-inventory --check: OK 5344/5344release-readiness.sh --json:user_release_ready: yes(north-star5-fast + VM driver probe OK)Verification
\E::Bthen0:A/1:B(matches Zend)Closes #5626
Made with Cursor