mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-04 08:04:37 +08:00
An unpinned generic declaration compared with `===`/`!==` takes its signature from the other operand (`held === ident`), which clears the pi `agent-session.ts:590` shape. That pin alone would answer `false` where JavaScript answers `true` when the program also holds the declaration at another signature, so a whole-program check refuses the comparison instead. It covers the direct form and values compared through `unknown` (the g5 silent divergence: two instances of one declaration compared unequal), resolving dynamic operands' provenance only when some declaration is held at more than one signature. - generic-functions: `identityComparisonPin` and `checkGenericIdentityPins` (runs once at the end of lowering, when every value instance is known); `GenericFnInfo.valueInstances` records the instances value references produced. - Corpus: `generic-identity-pin.ts`, `generic-identity-unknown.ts`. - Diagnostics: `generic-identity-multiple-pins.ts`, `generic-identity-unknown.ts`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 lines
447 B
TypeScript
12 lines
447 B
TypeScript
// The program holds `ident` at two signatures and compares a value of one
|
|
// against the declaration by identity. JavaScript has one function object;
|
|
// the compiled program has one closure per signature, so the comparison is
|
|
// refused rather than answered `false`.
|
|
type Fn = (x: number) => number;
|
|
function ident<T>(x: T): T {
|
|
return x;
|
|
}
|
|
const num: Fn = ident;
|
|
const str: (x: string) => string = ident;
|
|
console.log(num === ident, str("a"));
|