Skip to content

The value of $obj[$k] = $v used as an expression is 0/garbage instead of $v for an ArrayAccess object #397

Closed

Description

@blacktrs

Summary

The value of $obj[$k] = $v used as an expression is 0/garbage instead of $v for an ArrayAccess object.

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]); }
}
$b = new Box();
var_dump($b[0] = 2.5);
var_dump(($b[1] = 3) + 1);
$s = new SplFixedArray(2);
var_dump($s[0] = 2.5);

Expected (php)

float(2.5)
int(4)
float(2.5)

Actual (manticore 515a500a, Darwin arm64)

float(0)
int(1)
float(0)

Tracking

Known-bug repro: tests/aot/repro/wrong/arrayaccess_assign_expression_value.php — bash tests/aot/xfail.sh -k arrayaccess_assign_expression_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.

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