Files
scriptc/tests/diagnostics/stdlib-snapshot-value-use.ts
T
Malte UblandClaude Opus 5.5 caf098eff9 Refuse a stdlib-global snapshot read as a value
`const proc = globalThis.process` lowers to alias plumbing: the declaration
emits no storage and no code, because member and call reads resolve through
the global it names. A read that needs the VALUE therefore failed at the use
with the generic "binding form with no lowering", which names neither the
declaration nor the cause.

Register every stdlib-global snapshot declaration (TypeScript sources only,
matching the elision) and report the cause at the declaration (SC2020),
naming the global and, when it has a short spelling, the type the program
asked the compiler to hold. The use site keeps the inherited-blocker cascade
(SC2004) instead of the generic text.

An unread snapshot stays elided: reading a global has no side effects, so
dropping an unread `const p = process` is observationally identical to Node,
and refusing it would break programs that compile harmlessly today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 17:58:04 -07:00

11 lines
469 B
TypeScript

// The snapshot's declaration emits no storage: only reads that resolve
// THROUGH the global (members, calls) can exist. A read that needs the
// value reports the declaration's cause — the binding, the global it
// snapshots and why neither holds a value — and the use site carries the
// inherited-blocker cascade instead of "a binding form with no lowering".
function label(): unknown {
const proc = globalThis.process;
return proc;
}
console.log(label());