Skip to content

A call used as the base of a compound write is evaluated more than once #29

Closed

Description

@blacktrs

Summary

A call used as the base of a compound write is evaluated more than once.

Repro

<?php
final class O { public int $n = 0; public array $arr = ['a']; }
$calls = 0;
function mk(): O { global $calls; $calls++; return new O(); }
mk()->n++;
echo $calls, "\n";
mk()->arr[0] .= 'z';
echo $calls, "\n";
$c = true;
$c && (mk()->arr[] = 1);
echo $calls, "\n";
echo (string)(mk()->arr[] = 5), " ", $calls, "\n";

Expected (php 8.5)

1
2
3
5 4

Actual (manticore 10affa68, macOS arm64)

1
2
5
5 6

Tracking

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