Skip to content

A by-ref argument fed from a spread lands in a throwaway slot #61

Closed

Description

@blacktrs

Summary

A by-ref argument fed from a spread lands in a throwaway slot.

Repro

<?php
function f(&$x) { $x = 5; }
$args = [1];
f(...$args);
echo json_encode($args), "\n";

Expected (php 8.5)

[5]

Actual (manticore 10affa68, macOS arm64)

[1]

Tracking

Known-bug repro: tests/aot/repro/wrong/spread_into_byref.php — bash tests/aot/xfail.sh -k spread_into_byref 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
    on Oct 13, 2026
  3. blacktrs commented on Oct 13, 2026

    @blacktrs
    ContributorAuthor

    Scope: emitter change. f(...$args) into a by-ref param: the spread is expanded in emitSpreadFill, which copies elements by value. Binding by-ref needs element addresses plus write-back with copy-on-write separation of the source array. Not fixable in lowering. Repro: tests/aot/repro/wrong/spread_into_byref.php.

  4. blacktrs commented on Oct 24, 2026

    @blacktrs
    ContributorAuthor

    Spread into a by-ref parameter is also the one shape left open from #352. The fix for #352 (branch fix/refs-r4-r3, a62b0dd5) covers inherited constructors and first-class callables. $g->keep(...$arr), where keep stores its by-ref argument, is not covered and stays tracked here. The reduced repro is tests/aot/repro/wrong/spread_into_byref.

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:refsbugneeds-designwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions