Skip to content

Post-increment used as a value yields the NEW value (property and plain local) #56

Closed

Description

@blacktrs

Summary

Post-increment used as a value yields the NEW value (property and plain local).

Repro

<?php
final class O { public int $n = 1; }
$o = new O();
$x = $o->n++;
echo $x, " ", $o->n, "\n";
$l = 5;
$y = $l++;
echo $y, " ", $l, "\n";

Expected (php 8.5)

1 2
5 6

Actual (manticore 10affa68, macOS arm64)

2 2
5 6

Tracking

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

    @blacktrs
    ContributorAuthor

    Related repro: post-increment of a property inside a comparison behaves as pre-increment.

    <?php
    final class C { public int $n = 0; public function a(): ?int { return $this->n++ < 3 ? $this->n : null; } }
    $c = new C();
    var_dump($c->a(), $c->a(), $c->a(), $c->a());

    php: int(1) int(2) int(3) NULL
    manticore: int(1) int(2) NULL NULL

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