Skip to content

break inside a by-ref foreach drops the edits to $v #42

Closed

Description

@blacktrs

Summary

break inside a by-ref foreach drops the edits to $v.

Repro

<?php
$a = [1, 2, 3];
foreach ($a as &$v) { $v = 9; break; }
unset($v);
echo json_encode($a), "\n";

Expected (php 8.5)

[9,2,3]

Actual (manticore 10affa68, macOS arm64)

[1,2,3]

Tracking

Known-bug repro: tests/aot/repro/wrong/foreach_byref_break.php — bash tests/aot/xfail.sh -k foreach_byref_break reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

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