Skip to content

Fix substitution in bindAuxiliaryDict

Simon Peyton Jones requested to merge wip/T21391 into master

In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily calling extendInScope to bring into scope variables that were /already/ in scope. Worse, GHC.Core.Subst.extendInScope strangely deleted the newly-in-scope variables from the substitution -- and that was fatal in #21391 (closed).

I removed the redundant calls to extendInScope.

More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins) to stop deleting variables from the substitution. I even changed the names of the function to extendSubstInScope (and cousins) and audited all the calls to check that deleting from the substitution was wrong. In fact there are very few such calls, and they are all about introducing a fresh non-in-scope variable. These are "OutIds"; it is utterly wrong to mess with the "InId" substitution.

I have not added a Note, because I'm deleting wrong code, and it'd be distracting to document a bug.

Closes #21391 (closed).

Edited by Ben Gamari

Merge request reports