Skip to content
Snippets Groups Projects
Commit 8273d7d1 authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

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
parent 55af20e6
No related branches found
No related tags found
Loading
Loading
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