Keep the process.versions scan flag on the lowerer (#1579)

This commit is contained in:
Chris Tate
2026-10-20 18:38:46 -05:00
committed by GitHub
2 changed files with 7 additions and 10 deletions
@@ -304,19 +304,13 @@ export function isOptionalProcessVersionsRead(lowerer: Lowerer, node: ts.Node):
);
}
const mentionsVersions = new WeakMap<Lowerer, boolean>();
/** Whether any implementation source spells `versions`. Programs that
* never do skip the per-read checker queries above entirely. */
function programMentionsVersions(lowerer: Lowerer): boolean {
let known = mentionsVersions.get(lowerer);
if (known === undefined) {
known = lowerer.program
.getImplementationSourceFiles()
.some((sf) => !sf.isDeclarationFile && sf.text.includes("versions"));
mentionsVersions.set(lowerer, known);
}
return known;
lowerer.mentionsProcessVersions ??= lowerer.program
.getImplementationSourceFiles()
.some((sf) => !sf.isDeclarationFile && sf.text.includes("versions"));
return lowerer.mentionsProcessVersions;
}
export function lowerProcessStreamProperty(
@@ -1846,6 +1846,9 @@ export class Lowerer {
* NaN, which lower to plain doubles (see nan-coded-reads.ts). Settled by
* analyzeRuntimeOptionalArrayReads before any body lowers. */
nanCodedReads: NanCodedReads | null = null;
/** Whether any implementation source spells `versions`
* (programMentionsVersions in builtins/process.ts). */
mentionsProcessVersions: boolean | undefined = undefined;
private stringIndexBoundsCache: StringIndexBounds | null = null;
/** Proofs that a string element read names an existing code unit. The
* indexed-read analysis and expression lowering share one instance, so a