Skip to content

Regression: string offset assign of array omits Array to string conversion warning (Zend/zend_execute.c) #22925

Description

@PurHur

Category

bug · php-src-strict · language · string offsets

Problem

Assigning an array to a string offset must emit E_WARNING: Array to string conversion before Only the first byte will be assigned to the string offset, then write the first byte of "Array" (A). The VM skips the Array-to-string warning and only emits the first-byte warning (result string still matches).

Distinct from #22895 (illegal dimension types → TypeError) and #22897 (assign-op on string offset).

Verified 2026-07-24 (Zend 8.2.32 vs php bin/vm.php, error_reporting(E_ALL)):

Repro Zend 8.2 VM
$s="ab"; $s[0]=[]; Warning: Array to string conversion and Warning: Only the first byte… → 'Ab' Only first-byte warning → 'Ab'

php-src reference

PHP implementation target

  • lib/VM/ string-offset assign path — coerce array RHS via Zend-compatible cast (emit Array to string conversion) before first-byte assign
  • JIT string-offset lowering must agree; no new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'php -r '"'"'error_reporting(E_ALL); $s="ab"; $s[0]=[]; var_export($s); echo "\n";'"'"''
./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '"'"'error_reporting(E_ALL); $s="ab"; $s[0]=[]; var_export($s); echo "\n";'"'"''

Done when

  • Assigning [] (and other arrays) to a string offset emits Array to string conversion like Zend
  • First-byte warning + resulting string unchanged vs Zend
  • Compliance .phpt guard; php-src-strict; no php-compiler-strict shortcut

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions