summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-02-22 21:29:18 -0500
committerBen Gamari <ben@smart-cactus.org>2022-02-23 13:40:34 -0500
commit8bbdba450980c2b0054e19ae737eeaa3cfdb452d (patch)
treef8f8b2a58b0b0bd8c9055f164ce0f25e0ff41810
parentdd0ac6e5fdc8e4d2cdc52267bfa829ff27ec4bd7 (diff)
downloadhaskell-8bbdba450980c2b0054e19ae737eeaa3cfdb452d.tar.gz
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 4ff4d434e9a90623afce00b43e2a5a1ccbdb4c05. 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 0f7dc6701cfb6be59deb8601da8da000fe70263f)
-rw-r--r--compiler/GHC/Core/Rules.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Rules.hs b/compiler/GHC/Core/Rules.hs
index ccfbbe6a78..96f9bece4c 100644
--- a/compiler/GHC/Core/Rules.hs
+++ b/compiler/GHC/Core/Rules.hs
@@ -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 ---------------------