Skip to content

A reified class whose binding changes a property's layout coerces an argument that does not fit the binding instead of keeping it. #135

Closed

Description

@blacktrs

Summary

A reified class whose binding changes a property's layout coerces an argument that does not fit the binding instead of keeping it.

Repro

<?php
/** @template T */
final class Bag
{
    /** @var array<int, T> */
    private array $items = [];
    /** @param T $v */
    public function add(mixed $v): void { $this->items[] = $v; }
    public function kinds(): string { return implode(',', array_map('get_debug_type', $this->items)); }
}
/** @var Bag<float> $b */
$b = new Bag();
$b->add(1.5);
$b->add(5);
$b->add("7");
echo $b->kinds(), "\n";

Expected (php)

float,int,string

Actual (manticore 9358b6db, Darwin arm64)

float,float,float

Tracking

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

    @blacktrs
    ContributorAuthor

    Scope: decision needed (throw vs route to origin). A reified/bound generic coerces a misfit argument to the binding's type. The direct call path to the specialized class coerces; the existing claimParams/claimCheck route to the origin body exists only for erased thunks and only when the layout matches. For a layout-changing binding (e.g. Bag<float>) the origin body cannot run on the object, so the options are: (a) throw TypeError/ValueError at the boundary (matches the 'narrowing out of range is explicit, never silent' rule), or (b) give up the binding. Proposed: (a), with the check added at direct call sites. Found in batch E; not changed.

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