Skip to content

unset() of a local that a callee stored by reference does not disconnect it: later writes through the stored reference revive the variable #340

Closed

Description

@blacktrs

Summary

unset() of a local that a callee stored by reference does not disconnect it: later writes through the stored reference revive the variable.

Repro

<?php
class S {
    /** @var array<int,mixed> */
    public array $r = [];
    function bc(mixed &$v): void { $this->r[0] = &$v; }
    function set(): void { foreach ($this->r as &$r) { $r = 5; } unset($r); }
}
function f() { $s = new S; $s->bc($a); unset($a); $s->set(); var_dump(isset($a)); }
f();

Expected (php)

bool(false)

Actual (manticore e451c4c9, Darwin arm64)

bool(true)

Tracking

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