Skip to content

A by-ref arg stored by an inherited constructor, first-class callable or spread call is passed as a stale copy. #352

Closed

Description

@blacktrs

Summary

A by-ref arg stored by an inherited constructor, first-class callable or spread call is passed as a stale copy.

Repro

<?php
class B { public array $r = []; function __construct(mixed &$v = null) { if ($v !== null) $this->r[] = &$v; } function keep(mixed &$v) { $this->r[] = &$v; } }
class K extends B {}
$x = 1; $k = new K($x); $x = 2; echo $k->r[0], "\n";
$h = new B; $a = 1; $f = $h->keep(...); $f($a); $a = 2; echo $h->r[0], "\n";
$g = new B; $arr = [1]; $g->keep(...$arr); $arr[0] = 2; echo $g->r[0], "\n";

Expected (php)

2
2
2

Actual (manticore 868c12ed, Darwin arm64)

1
0
0

Tracking

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