-
Simon Peyton Jones authored
A very important invariant of the simplifier is that we do not simplify an arbitrarily large expression more than once in a single pass. If this can happen, then we can get exponential behaviour, when the large expression itself has a large sub-expression which is simplified twice, and so on. GHC has a long-standing bug which allows this repeated simplification to happen. It shows up when we have a function like this f d BIG where f's unfolding looks like \x -> case x of (a,b) -> a Of course this is v common for overloaded functions. Before this patch we simplified all the args (d and BIG) before deciding to unfold f. Then we push back the simplified BIG onto the continuation stack, inline f, so now we have (case d of (a,b) -> a) BIG After we reduce the case a bit, we'll simplify BIG a second time. And that's the problem. The quick-and-dirty solution is to keep a flag in the ApplyTo continuation to say whather the arg has already been simplified. An alternative would be to simplify it when first encountered, but that's a bigger change.
c43e5edf