Skip to content

simplCore: Correctly extend in-scope set in rule matching

Ben Gamari requested to merge wip/T21122 into master

Note [Matching lets] in GHC.Core.Rules claims the following:

We use GHC.Core.Subst.substBind to freshen the binding, using an in-scope set that is the original in-scope variables plus the rs_bndrs (currently floated let-bindings).

However, previously the implementation didn't actually do extend the in-scope set with rs_bndrs. This appears to be a regression which was introduced by 4ff4d434. Reintroduce rs_bndrs into the in-scope set, ensuring that let-binders cannot shadow one another due to rule rewrites.

Fixes #21122 (closed).

Also includes two other trivial commits fixing other issues which I noticed while investigating this.

Edited by Ben Gamari

Merge request reports