Skip to content

file-scope use(&$x): overwriting $x inside the closure must destroy the old object at once; native destroys it only at shutdown #69

Closed

Description

@blacktrs

Summary

file-scope use(&$x): overwriting $x inside the closure must destroy the old object at once; native destroys it only at shutdown.

Repro

<?php
// item: 15
class D { function __construct(public string $n) {} function __destruct() { echo "dtor {$this->n}\n"; } }
$x = new D("x");
$inc = function () use (&$x) { $x = new D("x2"); };
$inc();
echo "end\n";

Expected (php)

dtor x
end
dtor x2

Actual (manticore 09cb49fb, Darwin arm64)

end
dtor x
dtor x2

Tracking

Known-bug repro: tests/aot/repro/wrong/byref_capture_overwrite_dtor_late.php — bash tests/aot/xfail.sh -k byref_capture_overwrite_dtor_late 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 5, 2026
  2. added
    needs-design
    area:refs
    area:types
    on Oct 13, 2026
  3. blacktrs commented on Oct 13, 2026

    @blacktrs
    ContributorAuthor

    Scope: erased by-ref channel. Inside the closure the by-ref captured variable (use (&$x), file scope) is an erased unknown param, so the store has no representation flavor to release the OLD value with; the old object lives until shutdown. Fix needs the by-ref capture to carry a self-describing/typed channel (same family as #59 and 'erased/aliased channel NOT self-describing'). Found in batch B; skipped.

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:refsarea:typesbugneeds-designwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions