Skip to content

Remove or re-wire fromIR's apparently dead topLevelNames parameter #320

Description

@Unisay

Problem

Language.PureScript.Backend.Lua.fromIR takes a topLevelNames :: Set Lua.Name parameter that selects, for a local reference whose qualified form is a known top-level name, the module-table read M.name instead of a plain variable — and analogously selects SelfField self-references for recursive groups. Every call site in fromUberModule passes it empty (Set.empty/mempty), and the internal recursion only propagates the parameter, so the branches keyed on it appear unreachable:

exp  asExpression <$> fromIR foreigns Set.empty Set.empty modname irExp
...
IR.Local name
  | topLevelName  qualifyName modname (fromName name)
  , Set.member topLevelName topLevelNames 
      pure . Right $
        Lua.varField (Lua.varName Fixture.moduleName) topLevelName

(Quoted from main after #239, which added the separate unboxed-cells set — the second Set.empty — and kept the existing parameter untouched.)

Approach

Verify the parameter is genuinely dead (no caller constructs a non-empty set; git history shows what used to), then either remove it together with the two branches it feeds, or re-wire the actual top-level name set through if some caller was supposed to pass one and silently regressed. Removal simplifies fromIR's signature and deletes an untestable code path; re-wiring would need a test demonstrating a shape that requires it.

Relations

Observed while adding the unboxed-cells parameter in #239. Pure internal cleanup unless the investigation turns up a latent mis-lowering, in which case it becomes a bug with a reproduction.

Verification

If removed: the full suite stays green and no golden moves (proving the branches never fired). If re-wired: a new golden demonstrating the shape that needs the module-table read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: codegenLua code generation / printingchoreMaintenance / infrastructure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions