ReviewOS

home-lang/home

fix(ts): preserve symbolic indexed-access generic defaults

#634
Closed chris opened this 8 days ago ·
8 days ago

Parent

  • #548
  • Correctness tracker: #416
  • Discovered while implementing #633

Problem

A generic default such as D = T["state"]["definition"] is reduced through T’s constraint while the declaration is recorded. If that result is unknown, later instantiation of Constructor<Schema> cannot recover the intended concrete Schema["state"]["definition"] type.

This is distinct from #633, where the lowered default still contains the earlier type parameter and only needs declaration-order substitution.

Acceptance criteria

  • Preserve dependent indexed-access defaults symbolically at generic declaration time.
  • Instantiate bare and partially supplied references using earlier effective arguments.
  • Match current TypeScript on valid assignments and invalid primitive/object controls.
  • Avoid re-entering arbitrary declaration HIR during use-site substitution.
  • Add focused checker and Program coverage.
  • Re-run the unchanged pinned Zod 4.5.2 graph with exact normalized diagnostic identity comparison.
  • Document accepted results and link commits/issues.
8 days ago

Implementation checkpoint:

  • Reproduced the same-file gap on current main: TypeScript 6.0.3 and native TypeScript 7.0.2 accept bare/partial/explicit valid controls and reject only three invalid locations; Home previously added two false positives because T["state"]["definition"] had collapsed to the constraint member.
  • The candidate preserves dependent indexed accesses as an interned TypeId graph only while lowering a type-parameter default. Declaration-order substitution then resolves the concrete graph; use sites do not revisit HIR.
  • Same-file Home now matches the TypeScript 7 diagnostic codes and all TypeScript accept/reject locations. Two-file Program coverage accepts the valid imported controls and rejects all three invalid controls.
  • Permanent focused checker and Program regressions pass. Full checker suites pass in Debug, ReleaseSafe, and ReleaseFast; the complete Program suite passes.
  • Pinned Zod 4.5.2 candidate runs remain exactly 604 diagnostics. Both complete sorted diagnostic-key sets equal current main SHA-256 b1507875d4327b4df2dce0fed41123d3d409d8f85aca7b05fcaf6d3777c29210: 0 added, 0 removed.

Documentation and final commit/push are next.

8 days ago

Shipped to main in f6a014d4ba9bc5d9344c9969a890e54c6fdaa541 (checker and regressions) and 773af240550ce65c7f00509312e38c822ef078f2 (benchmark docs and README).

Final evidence:

  • TypeScript 6.0.3, native TypeScript 7.0.2, and Home agree on all focused same-file accepted/rejected locations. Home matches TS7 exactly for the three invalid diagnostic codes.
  • The two-file Program reduction accepts bare/partial valid uses and rejects all three invalid controls across the serialized declaration boundary.
  • The candidate retains dependent indexed accesses as interned TypeIds only during type-parameter-default lowering. Declaration-order substitution resolves them without storing or revisiting declaration HIR.
  • Pinned Zod 4.5.2 remains 604 diagnostics, with 0 added and 0 removed versus post-#633 main. Both complete sorted identity sets have SHA-256 b1507875d4327b4df2dce0fed41123d3d409d8f85aca7b05fcaf6d3777c29210.
  • The final rebased tree passes the focused oracle, all 4,347 checker tests in Debug / ReleaseSafe / ReleaseFast, the complete Program suite, zig fmt, scoped pickier, and git diff --check.
  • Full record: https://github.com/home-lang/home/blob/main/docs/docs/TS_PERFORMANCE.md#symbolic-indexed-access-generic-defaults
  • README summary: https://github.com/home-lang/home#typescript-frontend-benchmark-snapshot

The recorded 23.02-second final-artifact run is transparency only; no counterbalanced same-semantics timing comparison was made. Recursive fixed-point behavior remains separately tracked by #639.

Sign in to comment on this issue.