Skip to content

A temporary returned through a T|false method return and used in a call chain is not destructed at the end of the statement. #334

Closed

Description

@blacktrs

Summary

A temporary returned through a T|false method return and used in a call chain is not destructed at the end of the statement.

Repro

<?php
class S { function __destruct() { echo "dtor\n"; } function v(): int { return 1; } }
class D { function mk(): S|false { $s = new S(); return $s; } }
$d = new D();
$x = $d->mk()->v();
echo "after\n";

Expected (php)

dtor
after

Actual (manticore 5b9a32ad, Darwin arm64)

after
dtor

Tracking

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