Files
scriptc/tests/diagnostics/local-class-type-query-js.js
T
Malte UblandClaude Opus 5.5 f649959609 Report refused local classes from speculative type queries again
The previous change dropped the diagnostics of a function-local class refused during a speculative whole-program type query, expecting the class's own declaration to report them. In JavaScript that declaration only defers them to a runtime fence, so two npm programs that the compile refused (stream-shims and node24-file-url-conversion, both SC1090) began to compile and diverged from Node at run time. The speculative query now leaves the refusal reported, as it was wherever such an analysis already caught the poison, and only stops the poison from escaping the compiler.

The JavaScript crash repro becomes a diagnostics fixture (local-class-type-query-js.js); the corpus program 6102 never crashed the base compiler and is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 12:05:25 -07:00

27 lines
831 B
JavaScript

// A whole-program analysis that queries types before reachability is known
// (the computed-key write census here, through `holder.p`) names a
// function-local class whose collection is refused. The refusal is reported,
// once, at the class; it used to crash the compiler with an uncaught
// PoisonError.
function main() {
const Project = class _Project {
constructor() {
this.name = "p";
}
close() {
if (this.missingFilesMap) {
this.missingFilesMap.clear();
this.missingFilesMap = void 0;
}
}
add(k) {
(this.missingFilesMap || (this.missingFilesMap = new Map())).set(k, 1);
}
};
const holder = { p: new Project() };
const key = process.argv.length > 5 ? String(process.argv.length) : "name";
holder.p[key] = "q";
console.log(holder.p.name);
}
main();