Skip to content
Snippets Groups Projects
Commit 8bbdba45 authored by Ben Gamari's avatar Ben Gamari
Browse files

simplCore: Correctly extend in-scope set in rule matching

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.

(cherry picked from commit 0f7dc670)
parent dd0ac6e5
No related branches found
No related tags found
No related merge requests found
......@@ -955,7 +955,7 @@ match renv subst e1 (Let bind e2) mco
| otherwise
= Nothing
where
(flt_subst', bind') = substBind (rv_fltR renv) bind
(flt_subst', bind') = substBind (rv_fltR renv `extendInScopeList` rs_bndrs subst) bind
new_bndrs = bindersOf bind'
------------------------ Lambdas ---------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment