Skip to content

An int local that a loop or one branch turns float reads float everywhere #47

Open

Description

@blacktrs

Summary

An int local that a loop or one branch turns float reads float everywhere.

Also listed in the docs/ROADMAP.md Tier 1 gap matrix.

Repro

<?php
function t(bool $b): void {
    $s = 1;
    if ($b) { $s = $s + 1.5; }
    var_dump($s);
    $z = 0;
    foreach ([] as $x) { $z += 1.5; }
    var_dump($z);
}
t(false);

Expected (php 8.5)

int(1)
int(0)

Actual (manticore 10affa68, macOS arm64)

float(1)
float(0)

Tracking

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

    @blacktrs
    ContributorAuthor

    Scope: needs value-range analysis (VRA). An int local that a loop or one branch turns float is typed float everywhere; the correct fix is per-use type splitting / union with ranges. Parked branch: vra. Skipped in the bug batches.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions