Skip to content

Compiler: fix var_export after void setIteratorClass misbind (#10778) - #16310

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-10778-arrayobject-getiteratorclass-var-export
Jul 5, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-10778-arrayobject-getiteratorclass-var-export

Conversation

@PurHur

@PurHur PurHur commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

Regression re #10778: after $ao->setIteratorClass('ArrayIterator'), var_export($ao->getIteratorClass(), true) wired both call args to the hoisted true literal instead of the MethodCall result — VM echoed 'true' not 'ArrayIterator'.

Root cause: slotForImmediateConstFetchPreludeCallArg() only skipped arg #0 for nested FuncCall producers (nestedFuncCallProducerBeforeTrailingConstFetchPreludes), not sibling MethodCall + ConstFetch patterns like getIteratorClass().

Fix (PHP lowering in lib/Compiler.php)

  • Treat MethodCall/StaticCall in sibling call + hoisted scalar const producer matching
  • Wire call + ConstFetch arg ordinals by CFG statement order
  • Extend nestedFuncCallProducerBeforeTrailingConstFetchPreludes for MethodCall separated by literal prelude

php-src reference

  • ext/spl/spl_array.c — spl_array_setIteratorClass / spl_array_getIteratorClass

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "ArrayObjectGetIterator|arrayobject_getiterator|arrayobject_iterator_class"'
# OK (5 tests, 5 assertions)

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_arrayobject_getiterator_after_set.php'
# 'ArrayIterator'

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_arrayobject_get_iterator_class.php'
# exit 0

Closes #10778

Made with Cursor

Wire sibling MethodCall + hoisted true/false/null call args by CFG order
so getIteratorClass() feeds var_export arg 0 after setIteratorClass().

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 703f6e0 into master Jul 5, 2026
@PurHur
PurHur deleted the agent/issue-10778-arrayobject-getiteratorclass-var-export branch July 5, 2026 05:34
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: ArrayObject::getIteratorClass() returns null after void setIteratorClass() in expression (ext/spl/spl_array.c)

1 participant