Skip to content

$s = &$other on a by-ref parameter does not rebind it: the next write still lands in the caller's variable. #347

Closed

Description

@blacktrs

Summary

$s = &$other on a by-ref parameter does not rebind it: the next write still lands in the caller's variable.

Repro

<?php
function h(string &$s): void { $other = "o"; $s = &$other; $s = "zz"; echo $other, "\n"; }
$b = "b"; h($b); echo $b, "\n";

Expected (php)

zz
b

Actual (manticore ecbec1c2, Darwin arm64)

o
b

Tracking

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