Skip to content

A reference stored to a typed by-ref param (int &$v) holds a copy, so later writes on either side are not shared. #344

Closed

Description

@blacktrs

Summary

A reference stored to a typed by-ref param (int &$v) holds a copy, so later writes on either side are not shared.

Repro

<?php
class H { public array $refs = []; function bi(int $k, int &$v): void { $this->refs[$k] = &$v; } }
function f(H $h): void { $a = 2; $h->bi(1, $a); $a = 3; echo $h->refs[1], "\n"; $h->refs[1] = 4; echo $a, "\n"; }
f(new H);

Expected (php)

3
4

Actual (manticore ecbec1c2, Darwin arm64)

2
3

Tracking

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