Simplifier loop through cast worker/wrapper
With HEAD, if you try to compile typecheck/should_compile/T11754, with -fmax-simplifer-iterations=8 you'll see that the simplifier just iterates:
==================== Simplifier iteration=2 ====================
---- Simplifier counts for Simplifier iteration=2
Total ticks: 8
8 UnfoldingDone
4 $cp1Differentiable_aGz
4 $cp1Differentiable_aGK
1 SimplifierDone 1
...
==================== Simplifier iteration=3 ====================
---- Simplifier counts for Simplifier iteration=3
Total ticks: 8
8 UnfoldingDone
4 $cp1Differentiable_sJZ
4 $cp1Differentiable_sK0
1 SimplifierDone 1
And so on indefinitely. The problem is that we have this
Rec { bar1 = /\ a b. \d1 d2. bar a b e1 e2
; bar = bar1 |> co }
The occurrence analyser picks bar1 as the loop breaker, so we inline bar into bar1 to get
Rec { bar1 = /\ a b. \d1 d2. (bar1 |> co) a b e1 e2 }
Then we push that cast to the right, in fact outside the entire lambda, to get
Rec { bar1 = (/\ a b. \d1 d2. bar1 a b e1 e2) |> co }
and then we do cast worker/wrapper to get
Rec { bar2 = /\ a b. \d1 d2. bar1 a b e1 e2
; bar1 = bar1 |> co }
and we are back to where we started.
Cure
I think we still want to do cast w/w for recursive functions. What's odd this one is bottom. So maybe disable cast w/w for bottoming functions?