Be more careful about quantification
This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole
Showing
- compiler/GHC/Tc/Gen/Bind.hs 36 additions, 5 deletionscompiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/HsType.hs 8 additions, 4 deletionscompiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Solver.hs 71 additions, 72 deletionscompiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Types/Constraint.hs 4 additions, 1 deletioncompiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Utils/Concrete.hs 9 additions, 2 deletionscompiler/GHC/Tc/Utils/Concrete.hs
- compiler/GHC/Tc/Utils/TcMType.hs 86 additions, 75 deletionscompiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Validity.hs 1 addition, 1 deletioncompiler/GHC/Tc/Validity.hs
- testsuite/tests/rep-poly/RepPolyArgument.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyArgument.stderr
- testsuite/tests/rep-poly/RepPolyDoBind.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyDoBind.stderr
- testsuite/tests/rep-poly/RepPolyDoBody1.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyDoBody1.stderr
- testsuite/tests/rep-poly/RepPolyDoBody2.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyDoBody2.stderr
- testsuite/tests/rep-poly/RepPolyLeftSection2.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyLeftSection2.stderr
- testsuite/tests/rep-poly/RepPolyMcBind.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyMcBind.stderr
- testsuite/tests/rep-poly/RepPolyMcBody.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyMcBody.stderr
- testsuite/tests/rep-poly/RepPolyMcGuard.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyMcGuard.stderr
- testsuite/tests/rep-poly/RepPolyNPlusK.stderr 1 addition, 1 deletiontestsuite/tests/rep-poly/RepPolyNPlusK.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- testsuite/tests/rep-poly/RepPolyRule1.stderr 4 additions, 4 deletionstestsuite/tests/rep-poly/RepPolyRule1.stderr
- testsuite/tests/rep-poly/RepPolyTupleSection.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/RepPolyTupleSection.stderr
- testsuite/tests/rep-poly/T12709.stderr 2 additions, 2 deletionstestsuite/tests/rep-poly/T12709.stderr
Loading
Please register or sign in to comment