Skip to content

A bound Map<string,int> reinterprets a stored value that does not fit V when it is read back by a matching key. #137

Closed

Description

@blacktrs

Summary

A bound Map<string,int> reinterprets a stored value that does not fit V when it is read back by a matching key.

Repro

<?php
use Manticore\Ds\Map;
/** @var Map<string,int> $m */
$m = new Map();
$m->set("a", "x");
$m->set("b", 2.5);
var_dump($m->get("a"));
var_dump($m["b"]);

Expected (php)

string(1) "x"
float(2.5)

Actual (manticore 9358b6db, Darwin arm64)

int(0)
int(0)

Tracking

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