Problem
Every production call of fromIR in fromUberModule (lib/Language/PureScript/Backend/Lua.hs) passes Set.empty for the topLevelNames parameter, so both branches guarded by Set.member ... topLevelNames (the special case in IR.Ref and the qualified local names in the Let/RecursiveGroup lowering) are dead code.
Beyond the noise, the dead Ref branch is a trap: it matches a Local name against top-level names while ignoring the reference's index, so if anyone ever passes a non-empty set, a local that shadows a top-level name would silently compile to an M.field access.
Approach
Remove the topLevelNames parameter and both guarded branches. This eliminates the trap and simplifies the fromIR signature.
Prerequisites / Relations
Dead-code / codegen cleanup, found during the 2026-07-02 backend audit. Independent. Resolves a hypothesis from the #37 session notes: the miscapture is not reachable today precisely because the set is always empty.
Verification / Measurement
The removal is behaviour-preserving — the structural and eval goldens are unchanged, confirming the branches were genuinely dead — and the Local-shadows-top-level miscompilation trap is no longer reachable because the code path no longer exists.
Problem
Every production call of
fromIRinfromUberModule(lib/Language/PureScript/Backend/Lua.hs) passesSet.emptyfor thetopLevelNamesparameter, so both branches guarded bySet.member ... topLevelNames(the special case inIR.Refand the qualified local names in theLet/RecursiveGrouplowering) are dead code.Beyond the noise, the dead
Refbranch is a trap: it matches aLocalname against top-level names while ignoring the reference's index, so if anyone ever passes a non-empty set, a local that shadows a top-level name would silently compile to anM.fieldaccess.Approach
Remove the
topLevelNamesparameter and both guarded branches. This eliminates the trap and simplifies thefromIRsignature.Prerequisites / Relations
Dead-code / codegen cleanup, found during the 2026-07-02 backend audit. Independent. Resolves a hypothesis from the #37 session notes: the miscapture is not reachable today precisely because the set is always empty.
Verification / Measurement
The removal is behaviour-preserving — the structural and eval goldens are unchanged, confirming the branches were genuinely dead — and the
Local-shadows-top-level miscompilation trap is no longer reachable because the code path no longer exists.