ReviewOS

home-lang/home

fix(ts): retain receiver types in generic interface callbacks

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

Underlying failure found while tracing #475 and #476 for async admission (#473, tracker #416). Both TS 6.0.3 and native TS 7.0.2 reject only the final assignment with TS2322; Home instead reports TS2339 on value.label because the contextual callback parameter becomes the uninstantiated T. This occurs in both a global script and an export-marked module, so it is not Promise-specific:

interface Mapper<T> { project<U>(callback: (value: T) => U): U; }
declare const mapper: Mapper<{ label: string }>;
const result = mapper.project(value => value.label);
const good: string = result;
const bad: number = result;

Trace receiver instantiation, generic signature substitution and declaration-based contextual parameter re-lowering. Preserve bound outer type parameters while inferring method-owned parameters, including nested callbacks, constraints/defaults and shadowed parameter names. Test inferred and explicit calls plus negative result/argument controls; do not add explicit callback annotations or type arguments to avoid the failure. Recursive generic method results (Box<t>/Deferred<t>) also need the #475 audit. No affected async workload is admitted to timing.

9 days ago

The focused regression confirms the receiver member signature is already correctly instantiated: (callback: (value: { label: string }) => U) => U. A later declaration-based parameter re-lowering step reconstructs it as (value: T) => any, discarding the receiver substitution. Investigating type-graph substitution for this stage rather than re-reading an annotation without its original environment; the inferred callback and wrong-result control remain unchanged.

9 days ago

The focused inferred receiver case now retains (value: { label: string }) => U and infers U = string, rejecting the final number assignment. Two independent causes were isolated: the contextual-parameter gate rejected the whole signature because its return U was unresolved, and late declaration re-lowering discarded receiver substitutions. The in-progress fix uses the instantiated type graph and checks whether the parameter itself is resolvable. Added block/expression/explicit-call, distinct receiver, nested callback, constraint/default and shadowing controls. TS 6.0.3 and native TS 7.0.2 agree on all shared positive/negative cases; full Home validation is in progress, including an additional nested-arrow contextual typing gap. No new timing claims or async admission yet.

9 days ago

The full checker gate caught a dependent rest-parameter regression in the typed event emitter case. The old AST re-lowering had also been repairing a lost dependency: Events[K] was eagerly expanded through K’s key-union constraint. The fix now keeps the constrained indexed access symbolic until substitution, and the existing rest-correlation regression passes again. Added a negative-control emitter case to verify selected payload/index types are not widened or erased. Explicit generic callback context now also uses supplied type arguments before checking the body, matching TS2322 at the body rather than TS2345 on the whole callback. Full-suite rerun remains required before commit.

9 days ago

All six new focused regression groups now pass (7/7 including the test root): inferred receiver results, block/function/explicit callbacks, nested/distinct receivers, constraints/defaults/shadowing, invalid arguments, and indexed rest payloads. The latter also exposed redundant callback-body checks; the checker now reuses an already-checked signature when its contextual parameter types are identical, including structurally identical instantiated objects. Full checker, program, driver, and optimized-binary gates are running in isolated build caches after disk exhaustion and external cache cleanup interrupted the earlier runs. No affected benchmark has been added or timed, and the existing published snapshot remains tied to 9e45e10.

9 days ago

Fixed and pushed to origin/main in 0612a90; validation documentation is in 262db42. Final gates: 4,232 checker tests, 99 program tests, 173 driver tests, 16 harness/report tests, all 72 shared TS 6.0.3 / native TS 7.0.2 / Home CLI checks, and validation of all 18 existing workloads plus 13 negative controls per compiler. Both frozen predicate hashes are unchanged. The six new families include positive/negative variants in script and module scope. No new timings were collected under concurrent workstation activity; the README table stays explicitly tied to its measured 9e45e10 snapshot. Details: https://github.com/home-lang/home/blob/main/docs/docs/TS_PERFORMANCE.md#generic-receiver-callback-validation-untimed

Sign in to comment on this issue.