simplifier: Zap Id unfoldings before constructing InScopeSet in simpleOptExpr
Care must be taken to remove unfoldings from `Var`s collected by exprFreeVars before using them to construct an in-scope set hence `zapIdUnfolding` in `init_subst`. Consider calling `simpleOptExpr` on an expression like ``` case x of (a,b) -> (x,a) ``` * One of those two occurrences of x has an unfolding (the one in (x,a), with unfolding x = (a,b)) and the other does not. (Inside a case GHC adds unfolding-info to the scrutinee's Id.) * But exprFreeVars just builds a set, so it's a bit random which occurrence is collected. * Then simpleOptExpr replaces each occurrence of x with the one in the in-scope set. * Bad bad bad: then the x in case x of ... may be replaced with a version that has an unfolding. Fixes #25790
Showing
- compiler/GHC/Core/SimpleOpt.hs 21 additions, 8 deletionscompiler/GHC/Core/SimpleOpt.hs
- testsuite/tests/ghci/should_run/T25790.hs 10 additions, 0 deletionstestsuite/tests/ghci/should_run/T25790.hs
- testsuite/tests/ghci/should_run/T25790.script 1 addition, 0 deletionstestsuite/tests/ghci/should_run/T25790.script
- testsuite/tests/ghci/should_run/all.T 1 addition, 0 deletionstestsuite/tests/ghci/should_run/all.T
Loading
Please register or sign in to comment