Fix infelicities in the Specialiser
On the way to #23109 (unary classes) I discovered some infelicities (or maybe tiny bugs, I forget) in the type-class specialiser. I also tripped over #25965, an outright bug in the rule matcher Specifically: * Refactor: I enhanced `wantCallsFor`, whih previously always said `True`, to discard calls of class-ops, data constructors etc. This is a bit more efficient; and it means we don't need to worry about filtering them out later. * Fix: I tidied up some tricky logic that eliminated redundant specialisations. It wasn't working correctly. See the expanded Note [Specialisations already covered], and (MP3) in Note [Specialising polymorphic dictionaries]. See also the new top-level `alreadyCovered` function, which now goes via `GHC.Core.Rules.ruleLhsIsMoreSpecific` I also added a useful Note [The (CI-KEY) invariant] * Fix #25965: fixed a tricky bug in the `go_fam_fam` in `GHC.Core.Unify.uVarOrFam`, which allows matching to succeed without binding all type varibles. I enhanced Note [Apartness and type families] some more * #25703. This ticket "just works" with -fpolymorphic-specialisation; but I was surprised that it worked! In this MR I added documentation to Note [Interesting dictionary arguments] to explain; and tests to ensure it stays fixed.
Showing
- compiler/GHC/Core/Opt/Specialise.hs 185 additions, 93 deletionscompiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Rules.hs 24 additions, 14 deletionscompiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Unify.hs 65 additions, 39 deletionscompiler/GHC/Core/Unify.hs
- compiler/GHC/Tc/Solver/Equality.hs 2 additions, 0 deletionscompiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Types/Basic.hs 1 addition, 1 deletioncompiler/GHC/Types/Basic.hs
- testsuite/tests/simplCore/should_compile/T25703.hs 7 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T25703.hs
- testsuite/tests/simplCore/should_compile/T25703.stderr 2 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T25703.stderr
- testsuite/tests/simplCore/should_compile/T25703a.hs 69 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T25703a.hs
- testsuite/tests/simplCore/should_compile/T25703a.stderr 6 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T25703a.stderr
- testsuite/tests/simplCore/should_compile/T25965.hs 18 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T25965.hs
- testsuite/tests/simplCore/should_compile/all.T 5 additions, 0 deletionstestsuite/tests/simplCore/should_compile/all.T
Loading
Please register or sign in to comment