mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
Whole-program analyses that query types before reachability is known (the computed-key write census for JavaScript method dispatch, and the runtime-optional array analysis) can name a function-local class whose collection is refused. No statement owns that refusal there, so it escaped as an uncaught PoisonError from collectClassShapeInner and crashed the compiler (the ts-api-utils probe, @typescript-eslint/typescript-estree, and small TypeScript programs). These analyses now run under Lowerer.speculativeTypeQueries: a refused local class is unmappable for the query and its diagnostics are dropped, and the class's own declaration collects it again and reports them if the program reaches it. Collection and body lowering keep their poison handling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 lines
421 B
TypeScript
15 lines
421 B
TypeScript
// A whole-program analysis queries the element type of `items` before any
|
|
// body lowers. The function-local class it names is refused: the refusal is
|
|
// reported once, at the class (it used to crash the compiler with an uncaught
|
|
// PoisonError).
|
|
function make() {
|
|
class Box {
|
|
static count = 0;
|
|
v = 1;
|
|
}
|
|
return new Box();
|
|
}
|
|
const items = [make()];
|
|
const first = items[0];
|
|
console.log(first ? first.v : 0);
|