Skip to content

Stdlib: AOT NoRewindIterator/InfiniteIterator foreach via HT+pos (#27583, #27568) - #27612

Merged
PurHur merged 1 commit into
masterfrom
agent/advanced-stdlib-27583-norewinditerator-aot
Aug 4, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/advanced-stdlib-27583-norewinditerator-aot

Conversation

@PurHur

@PurHur PurHur commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • AOT foreach over NoRewindIterator / InfiniteIterator was silently empty (rc=0) because thin AOT had no Iterator protocol wiring.
  • Snapshot inner __spl_ht, walk via __spl_iter_pos + Iterator methods; keep NoRewindIterator::rewind a no-op so a second foreach stays empty; InfiniteIterator::next wraps.
  • Prefer Iterator protocol over SplOuterIteratorHt so rewind semantics hold (php-src ext/spl/spl_iterators.c).

Closes #27583
Closes #27568

Test plan

  • NoRewind issue repro — Zend/VM/AOT print a1a2a3 (≥3 AOT runs)
  • Infinite issue repro — Zend/VM/AOT print 1,2,1,2,1
  • vendor/bin/phpunit --filter 'norewinditerator_foreach|infiniteiterator_foreach' → OK (2 AotTest)
  • php script/bootstrap-inventory.php --check → OK 6996/6996
  • php script/check-selfhost-spine-coverage-sync.php → OK
  • Not covered: full ci-fast / compliance suite / north-star5-verify-fast

Made with Cursor

, #27568)

Thin AOT lacked Iterator protocol for these OuterIterator wrappers, so foreach
was silently empty. Snapshot inner `__spl_ht`, walk via `__spl_iter_pos`, and
keep NoRewind::rewind a no-op so a second foreach stays empty; Infinite next()
wraps. Prefer Iterator protocol over SplOuterIteratorHt so rewind semantics hold.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant