Skip to content

Lua.fromIR: topLevelNames parameter is always empty, guarded branches are dead code #146

Description

@Unisay

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. Removing the parameter and both branches eliminates the trap and simplifies the signature.

Found during the 2026-07-02 backend audit (this resolves a hypothesis from the issue #37 session notes: the miscapture is not reachable today precisely because the set is always empty).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: codegenLua code generation / printingenhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions