Skip to content

$w = &$v where $v is itself bound by reference (a by-ref param, a by-ref foreach variable) overwrites the binding instead of writing through it. #440

Closed

Description

@blacktrs

Summary

$w = &$v where $v is itself bound by reference (a by-ref param, a by-ref foreach variable) overwrites the binding instead of writing through it.

Repro

<?php
function loop(): void { $arr = [1, 2]; foreach ($arr as &$v) { $w = &$v; $w = 'x'; } unset($v); var_dump($arr[0], $arr[1]); }
loop();
function param(&$p): void { $w = &$p; $w = 'six'; }
$s = 1; param($s); var_dump($s);

Expected (php)

string(1) "x"
string(1) "x"
string(3) "six"

Actual (manticore 1b3f58ac, Darwin arm64)

int(4300436936)
int(4300436936)
int(1)

Tracking

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