inlineLocalBindings (lib/Language/PureScript/Backend/IR/Optimizer.hs) folds over a Let's groupings with foldr and calls substitute (Local name) 0 for every Standalone binding. Index 0 is only correct for the binding whose binder is nearest in the body; with same-name sibling bindings in one Let (allowed by Note [Sequential scoping of Let bindings]) the earlier sibling's references sit at index 1 and are missed, and references inside an inlinee to a name rebound by a later sibling get captured by the wrong binder.
Same-name siblings cannot currently be produced from PureScript source (source let-blocks have unique names; generated names are fresh), so this is a latent landmine in the same class as the body-scope defect in #134.
Expected resolution: this dies by construction under the GUC redesign (#139), where all local binders are unique before the optimizer runs. Filing it separately so the hazard is on record in case inlining changes land before #139; if #139 lands first, close this with a regression test.
Found during the 2026-07-02 backend audit.
inlineLocalBindings(lib/Language/PureScript/Backend/IR/Optimizer.hs) folds over aLet's groupings withfoldrand callssubstitute (Local name) 0for everyStandalonebinding. Index 0 is only correct for the binding whose binder is nearest in the body; with same-name sibling bindings in oneLet(allowed by Note [Sequential scoping of Let bindings]) the earlier sibling's references sit at index 1 and are missed, and references inside an inlinee to a name rebound by a later sibling get captured by the wrong binder.Same-name siblings cannot currently be produced from PureScript source (source let-blocks have unique names; generated names are fresh), so this is a latent landmine in the same class as the body-scope defect in #134.
Expected resolution: this dies by construction under the GUC redesign (#139), where all local binders are unique before the optimizer runs. Filing it separately so the hazard is on record in case inlining changes land before #139; if #139 lands first, close this with a regression test.
Found during the 2026-07-02 backend audit.