Skip to content

Fix array_reduce([...], fn, []) enum identity + initial [] ARG_SEND (#5626) - #20012

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-5626-array-reduce-enum
Jul 17, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-5626-array-reduce-enum

Conversation

@PurHur

@PurHur PurHur commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes array_reduce([E::A, E::B], fn ($c, $i) => …, []) so the inline initial [] is not wired to the enum input INIT_ARRAY (ARG_SEND was $8,$9,$8 instead of $8,$9,$10).
  • Collects the input Array_ when a Closure sits between it and a trailing initial Array_ in precedingInlineCallArgProducersBeforeCfgOp.
  • Uses matchInlineCallArgProducer for array_reduce sibling Array_ ARG_SEND resolution (avoids matchInlineArrayProducersToArrayCallArgs binding the sole array-typed dead temp to the first Array_).
  • Adds 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.php call-arg hoist/ARG_SEND (VM ext/standard/array_reduce.php already preserved enum objects once args were correct).

Trust gates (pre-work)

  • docker info: OK
  • bootstrap-inventory --check: OK 5344/5344
  • release-readiness.sh --json: user_release_ready: yes (north-star5-fast + VM driver probe OK)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/issue_5626_array_reduce_enum.php
php bin/jit.php test/repro/issue_5626_array_reduce_enum.php
vendor/bin/phpunit test/compliance/VMTest.php --filter array_reduce
vendor/bin/phpunit test/compliance/JITTest.php --filter array_reduce
'
  • VM/JIT repro: \E::B then 0:A / 1:B (matches Zend)
  • VMTest array_reduce: OK (10 tests)
  • JITTest array_reduce: OK (9 tests)

Closes #5626

Made with Cursor

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>
@PurHur
PurHur merged commit 7aac270 into master Jul 17, 2026
@PurHur
PurHur deleted the agent/issue-5626-array-reduce-enum branch July 17, 2026 11:14
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.

Stdlib: array_reduce() on enum case arrays — closure callbacks must preserve enum objects (ext/standard/array.c)

1 participant