Fix bug in the short-cut solver
Trac #13943 showed that the relatively-new short-cut solver for class constraints (aka -fsolve-constant-dicts) was wrong. In particular, see "Type families" under Note [Shortcut solving] in TcInteract. The short-cut solver recursively solves sub-goals, but it doesn't flatten type-family applications, and as a result it erroneously thought that C (F a) cannot possibly match (C 0), which is simply untrue. That led to an inifinte loop in the short-cut solver. The significant change is the one line + , all isTyFamFree preds -- See "Type families" in + -- Note [Shortcut solving] but, as ever, I do some other refactoring. (E.g. I changed the name of the function to shortCutSolver rather than the more generic trySolveFromInstance.) I also made the short-cut solver respect the solver-depth limit, so that if this happens again it won't just produce an infinite loop. A bit of other refactoring, notably moving isTyFamFree from TcValidity to TcType
Showing
- compiler/typecheck/TcInteract.hs 83 additions, 52 deletionscompiler/typecheck/TcInteract.hs
- compiler/typecheck/TcType.hs 6 additions, 2 deletionscompiler/typecheck/TcType.hs
- compiler/typecheck/TcValidity.hs 0 additions, 4 deletionscompiler/typecheck/TcValidity.hs
- testsuite/tests/typecheck/should_compile/T13943.hs 68 additions, 0 deletionstestsuite/tests/typecheck/should_compile/T13943.hs
- testsuite/tests/typecheck/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_compile/all.T
Loading
Please register or sign in to comment