ReviewOS

home-lang/home

fix(ts): preserve declared callable identity across predicate and boolean signatures

#507
Closed chris opened this 9 days ago ·
9 days ago

Observed while integrating source-owned typed lookup for #480/#487 (tracker #416). Structurally identical callable signatures currently canonicalize to one TypeId while signature_predicates and declaration metadata are stored outside that key. This is observable even within one real module; cross-file copying cannot safely compose the same representation.

Repro (strict/noEmit/noLib with the benchmark minimal lib):

export {};
interface Guards {
  number(value: unknown): value is number;
  plain(value: unknown): boolean;
}
declare const guards: Guards;
declare let value: unknown;
const p = guards.plain;
if (p(value)) { const bad: number = value; }

TS 6.0.3 and native TS 7.0.2 report TS2322; Home accepts it. Direct guards.plain(value), an object wrapper alias, and assigning guards.plain to a numeric predicate type are also incorrectly accepted. A real numeric-guard alias is accepted correctly by all three. Before evidence: bench/vs_tsgo/results/signature-identity.6jiDkG/before.log (15 checks; four Home failures), using the preceding prepared-program release.

Fix callable identity/metadata ownership at the type representation boundary, not by adding expression-shape exceptions. Preserve structural assignability, generic instantiation, rest/optional semantics, declaration provenance, and transfer between source owners. Add positive/negative audits, both declaration orders, and regression tests. Keep global/import graph gates unchanged until actual typed lookup passes them; document any timing/admission effects.

9 days ago

The reproducible 56-case callable audit is now committed and pushed in d4e63ff (35 harness tests pass). Both installed baselines were checked: TS 6.0.3 and native TS 7.0.2. The pre-change Home binary passes 26/56; the fresh-identity candidate passes 56/56, including both declaration orders and script/module scopes. The implementation is not pushed yet: full checker validation exposed implicit identity dependencies in callback inference, substitution, and conditional callable unions, which are being corrected before publication. No new timing results or benchmark-win claims.

9 days ago

Fixed in 15f050f; permanent audit d4e63ff and results/README table 770834343. Callable signatures now retain distinct identities, structural assignability remains intact, transfer preserves callable ownership, and allocation failure cannot publish partial columns. Follow-on corrections preserve inferred metadata, isolate nested generic binders, retain unaffected substitution identities, and snapshot argument context across pool growth. Fresh TS 6.0.3/native TS 7.0.2 audit: Home 26/56 before, 56/56 after; both baselines 56/56. Checker 4257/4257, conformance 1417/1417, driver 186/186, program 105/105, CLI 69/69, harness 35/35. Tuple/assertion controls pass; global/imported-owner outcomes and both failed graph admission gates remain unchanged. No new timings. Details: https://github.com/home-lang/home/blob/main/docs/docs/TS_PERFORMANCE.md#callable-identity-and-scoped-inference-untimed

Sign in to comment on this issue.