Skip to content

A referenced local whose type changes reads a stale/raw word (use (&$d), $r = &$d) #59

Closed

Description

@blacktrs

Summary

A referenced local whose type changes reads a stale/raw word (use (&$d), $r = &$d).

Repro

<?php
$d = 1;
$f = function () use (&$d): void { $d = $d * 2; };
$d = 2.0;
$f();
var_dump($d);
$e = 1;
$r = &$e;
$e = 1.5;
var_dump($r);
function t(): void { $d = 1; $r = &$d; $r = "str"; var_dump($d); $r = [1]; var_dump($d); }
t();

Expected (php 8.5)

float(4)
float(1.5)
string(3) "str"
array(1) {
  [0]=>
  int(1)
}

Actual (manticore 10affa68, macOS arm64)

float(4)
int(4609434218613702656)
int(4307789184)
int(4307821904)

Tracking

Known-bug repro: tests/aot/repro/wrong/ref_retype.php — bash tests/aot/xfail.sh -k ref_retype 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 5, 2026
  2. added
    needs-design
    area:refs
    area:types
    on Oct 13, 2026
  3. blacktrs commented on Oct 13, 2026

    @blacktrs
    ContributorAuthor

    Scope: type-system work. A referenced local whose type changes (use (&$d), $r = &$d) needs the box and its representation to follow the retype across all aliases; today a by-ref write that changes the type leaves a stale/raw word. Related open item: erased/aliased channel is not self-describing. Repro: tests/aot/repro/wrong/ref_retype.php.

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

    area:refsarea:typesbugneeds-designwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions