Skip to content

Regression: ArrayIterator::current()/::key() string-concat nested operand — returns true not element (ext/spl/spl_array.c) #13901

Closed

Description

@PurHur

Category

stdlib · php-src-strict · regression (nested operand in string concatenation)

Problem

After ArrayIterator::next(), current() and key() must return the element value and integer key. When either method is a nested operand inside string concatenation with var_export(..., true), the VM returns true instead.

Standalone calls work; dot-concat form fails. Same failure class as pointer builtins (#13828 current(), #13830 next()).

php-src reference

Repro (verified 2026-06-30)

test/repro/maintainer_gap_arrayiterator_current_concat_only.php
test/repro/maintainer_gap_arrayiterator_key_concat.php

php bin/vm.php test/repro/maintainer_gap_arrayiterator_current_concat_only.php
php bin/vm.php test/repro/maintainer_gap_arrayiterator_key_concat.php
Check Zend VM
$it->next(); 'cur='.var_export($it->current(), true) cur=2 cur=true
$it->next(); 'key='.var_export($it->key(), true) key=1 key=true
Standalone $it->current() / $it->key() correct correct

Scope (PHP-in-PHP first)

Layer Path
VM ext/spl/ArrayIterator handlers or shared iterator method dispatch
Compiler nested-call / concat operand lowering
JIT after VM green

Check RecursiveArrayIterator and other Iterator implementations for the same concat pattern.

Done when (php-src-strict)

  • Both repros exit 0 on VM
  • Iterator methods return correct types in concat/nested contexts
  • JIT/AOT agree when in scope

Verification

php bin/vm.php test/repro/maintainer_gap_arrayiterator_current_concat_only.php
php bin/vm.php test/repro/maintainer_gap_arrayiterator_key_concat.php

Links

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 30, 2026
  2. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — batch (issues #13901)

  3. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Merged via #13910

    Fix: lib/Compiler.php — collect hoisted MethodCall siblings for var_export(..., true) in concat (same producer-slot path as #13828 FuncCall pointer builtins).

    Verification (green on master):

    php bin/vm.php test/repro/maintainer_gap_arrayiterator_current_concat_only.php  # ok
    php bin/vm.php test/repro/maintainer_gap_arrayiterator_key_concat.php           # ok
    php vendor/bin/phpunit --filter testVarExportNestedArrayIterator                # OK (2 tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions