G130: Generated Literal Sharing
Repeated immutable literal tables can be emitted once and referenced by multiple matchers, reducing generated data duplication.
Mechanism and Invariants
Interning keys use decoded literal contents. Each matcher retains its own description/expectation identity; sharing data cannot merge diagnostics or rule wrappers. Failed speculative lowering rolls back inserted literal entries and reserved declarations. Helper-body sharing is independently selected.
Scope and State
Default literal sharing in generated Go Node and typed Go. TypeScript literal sharing is an opt-in that no profile sets; helper sharing remains default there. Core closure/VM literals are separate compilation representations.
Reference Control
-no-opt literal-sharing selects duplicate tables. The optimization
ts-literal-sharing, off by default, opts into TypeScript literal sharing;
-no-opt literal-sharing takes precedence. These select generated source before parsing.
Evidence and Implementation
Record 090 compares helper-only, literal-only, combined and no-sharing outputs. It primarily supports source/build-cost reduction; mixed TypeScript literal results did not justify default adoption. Combined ratios do not isolate literal sharing alone.
Evidence records: 090.
Source owners: the literal registry of the generator state,
TypeScript literal sharing selection.
The comparison policy distinguishes same-source controls, historical changes and full checkpoints.