Skip to content

The value of $o[$k] = <string built at run time> as an expression is garbage; php yields the assigned string #420

Closed

Description

@blacktrs

Summary

The value of $o[$k] = <string built at run time> as an expression is garbage; php yields the assigned string.

Repro

<?php
class Box implements ArrayAccess {
    private array $d = [];
    public function offsetExists(mixed $o): bool { return isset($this->d[$o]); }
    public function offsetGet(mixed $o): mixed { return $this->d[$o]; }
    public function offsetSet(mixed $o, mixed $v): void { $this->d[$o] = $v; }
    public function offsetUnset(mixed $o): void { unset($this->d[$o]); }
}
function mk(string $s): string { return "a" . $s; }
$b = new Box();
$x = $b[0] = mk("z");
var_dump($x);
$y = $b[1] = "k" . $x;
var_dump($y);

Expected (php)

string(2) "az"
string(3) "kaz"

Actual (manticore 35461ba2, Darwin arm64)

NULL
NULL

Tracking

Known-bug repro: tests/aot/repro/wrong/arrayaccess_assign_expression_value_of_heap_value.php — bash tests/aot/xfail.sh -k arrayaccess_assign_expression_value_of_heap_value reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 24, 2026
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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions