Skip to content

A closure literal in an arm of a conditional callee is never released: ($f ?? function () {...})() keeps the env and its captures alive. #590

Open

Description

@blacktrs

Summary

A closure literal in an arm of a conditional callee is never released: ($f ?? function () {...})() keeps the env and its captures alive.

Repro

<?php
class H { public function __destruct() { echo "drop\n"; } }
class F {
    public static ?Closure $f = null;
    public static function run() { $k = new H(); return (static::$f ?? function () use ($k) { return 1; })(); }
}
F::run();
echo "end\n";

Expected (php)

drop
end

Actual (manticore 823c14a7, Darwin arm64)

end
drop

Tracking

Known-bug repro: tests/aot/repro/leak/closure_literal_arm_of_conditional_callee.php — bash tests/aot/xfail.sh -k closure_literal_arm_of_conditional_callee 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
    leak
    on Nov 7, 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

    bugleak

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions