Problem
Freshened binders and pipeline-minted names draw from one global counter (SupplyM, the fresh-name supply threaded through the IR pipeline), so an optimizer change that consumes more or fewer fresh names at any point shifts every name generated after it. Structural goldens then diff on lines whose only change is the counter value. Verbatim from PR #337, in Golden.LongWriterBind.Test/golden.ir — the module's only semantic change is the Data.Tuple.Tuple$w constructor worker dissolving, and its golden.lua moved 112 bytes, yet the .ir diff carries 94 changed lines, many of the shape:
- ( Nothing, Name "m$548", AppN Nothing
+ ( Nothing, Name "m$590", AppN Nothing
Every optimizer PR pays this tax: semantic changes hide among renumberings (PR #337 inserted ~10.8k golden lines, a real fraction counter-only), reviewers must distinguish real rewrites from shifted counters, and modules whose generated code did not meaningfully change still churn their goldens. The uniquifier's x_S_N suffixes in golden.lua shift the same way when a pass introduces or drops binders upstream.
Approach
Two candidate shapes, not mutually exclusive. (a) Stabilize the names at the source: derive fresh names from local context (e.g. a per-binding or per-module counter seeded from the host binding's name) instead of one global sequence, so a change in module A cannot renumber module B. (b) Normalize in the golden harness: alpha-rename generated names (m$N, _S_N suffixes) to a canonical per-binding numbering before writing golden.ir/golden.lua, confining the fix to the test harness and leaving the pipeline untouched. (b) is cheaper and removes the review noise; (a) additionally stabilizes the shipped Lua output, which matters for downstream diffing of compiled artifacts.
Prerequisites / Relations
Surfaced while landing #245 (PR #337), where counter-only churn inflated the golden diff. No blockers.
Verification / Measurement
A pipeline change that consumes extra fresh names in one module leaves unrelated modules' goldens byte-identical. Concretely: re-running golden generation with an artificially offset supply start must produce identical goldens (under normalization) or identical names (under local counters); the Golden.LongWriterBind shape above is the regression witness.
Problem
Freshened binders and pipeline-minted names draw from one global counter (
SupplyM, the fresh-name supply threaded through the IR pipeline), so an optimizer change that consumes more or fewer fresh names at any point shifts every name generated after it. Structural goldens then diff on lines whose only change is the counter value. Verbatim from PR #337, inGolden.LongWriterBind.Test/golden.ir— the module's only semantic change is theData.Tuple.Tuple$wconstructor worker dissolving, and itsgolden.luamoved 112 bytes, yet the.irdiff carries 94 changed lines, many of the shape:Every optimizer PR pays this tax: semantic changes hide among renumberings (PR #337 inserted ~10.8k golden lines, a real fraction counter-only), reviewers must distinguish real rewrites from shifted counters, and modules whose generated code did not meaningfully change still churn their goldens. The uniquifier's
x_S_Nsuffixes ingolden.luashift the same way when a pass introduces or drops binders upstream.Approach
Two candidate shapes, not mutually exclusive. (a) Stabilize the names at the source: derive fresh names from local context (e.g. a per-binding or per-module counter seeded from the host binding's name) instead of one global sequence, so a change in module A cannot renumber module B. (b) Normalize in the golden harness: alpha-rename generated names (
m$N,_S_Nsuffixes) to a canonical per-binding numbering before writinggolden.ir/golden.lua, confining the fix to the test harness and leaving the pipeline untouched. (b) is cheaper and removes the review noise; (a) additionally stabilizes the shipped Lua output, which matters for downstream diffing of compiled artifacts.Prerequisites / Relations
Surfaced while landing #245 (PR #337), where counter-only churn inflated the golden diff. No blockers.
Verification / Measurement
A pipeline change that consumes extra fresh names in one module leaves unrelated modules' goldens byte-identical. Concretely: re-running golden generation with an artificially offset supply start must produce identical goldens (under normalization) or identical names (under local counters); the
Golden.LongWriterBindshape above is the regression witness.