Finish fix for #14880.
authorTobias Dammers <tdammers@gmail.com>
Thu, 13 Sep 2018 07:56:02 +0000 (09:56 +0200)
committerRichard Eisenberg <rae@cs.brynmawr.edu>
Mon, 29 Oct 2018 03:17:47 +0000 (23:17 -0400)
commit5e45ad10ffca1ad175b10f6ef3327e1ed8ba25f3
tree41449e2a558385d2b290d0005fec353e6c9c88dd
parente8a652f65318cf60e856f7c2777a003eba10ddc6
Finish fix for #14880.

The real change that fixes the ticket is described in
Note [Naughty quantification candidates] in TcMType.

Fixing this required reworking candidateQTyVarsOfType, the function
that extracts free variables as candidates for quantification.
One consequence is that we now must be more careful when quantifying:
any skolems around must be quantified manually, and quantifyTyVars
will now only quantify over metavariables. This makes good sense,
as skolems are generally user-written and are listed in the AST.

As a bonus, we now have more control over the ordering of such
skolems.

Along the way, this commit fixes #15711 and refines the fix
to #14552 (by accepted a program that was previously rejected,
as we can now accept that program by zapping variables to Any).

This commit also does a fair amount of rejiggering kind inference
of datatypes. Notably, we now can skip the generalization step
in kcTyClGroup for types with CUSKs, because we get the
kind right the first time. This commit also thus fixes #15743 and
 #15592, which both concern datatype kind generalisation.
(#15591 is also very relevant.) For this aspect of the commit, see
Note [Required, Specified, and Inferred in types] in TcTyClsDecls.

Test cases: dependent/should_fail/T14880{,-2},
            dependent/should_fail/T15743[cd]
            dependent/should_compile/T15743{,e}
            ghci/scripts/T15743b
            polykinds/T15592
            dependent/should_fail/T15591[bc]
            ghci/scripts/T15591
86 files changed:
compiler/basicTypes/Var.hs
compiler/basicTypes/VarSet.hs
compiler/coreSyn/MkCore.hs
compiler/deSugar/DsBinds.hs
compiler/main/HscTypes.hs
compiler/prelude/TysWiredIn.hs-boot
compiler/rename/RnTypes.hs
compiler/simplCore/SetLevels.hs
compiler/simplCore/SimplUtils.hs
compiler/specialise/SpecConstr.hs
compiler/typecheck/FamInst.hs
compiler/typecheck/TcClassDcl.hs
compiler/typecheck/TcDeriv.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcGenGenerics.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRules.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcSigs.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcValidity.hs
compiler/types/TyCoRep.hs
compiler/types/TyCon.hs
compiler/types/Type.hs
compiler/types/Type.hs-boot
compiler/types/Unify.hs
compiler/utils/UniqDFM.hs
compiler/utils/UniqDSet.hs
compiler/utils/Util.hs
docs/users_guide/glasgow_exts.rst
docs/users_guide/using.rst
testsuite/tests/dependent/should_compile/InferDependency.hs [moved from testsuite/tests/dependent/should_fail/InferDependency.hs with 100% similarity]
testsuite/tests/dependent/should_compile/T14066a.stderr
testsuite/tests/dependent/should_compile/T14880-2.hs [new file with mode: 0644]
testsuite/tests/dependent/should_compile/T14880-2.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_compile/T14880.hs [new file with mode: 0644]
testsuite/tests/dependent/should_compile/T15743.hs [new file with mode: 0644]
testsuite/tests/dependent/should_compile/T15743.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_compile/T15743e.hs [new file with mode: 0644]
testsuite/tests/dependent/should_compile/T15743e.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_compile/all.T
testsuite/tests/dependent/should_fail/InferDependency.stderr [deleted file]
testsuite/tests/dependent/should_fail/SelfDep.stderr
testsuite/tests/dependent/should_fail/T13895.stderr
testsuite/tests/dependent/should_fail/T14066d.stderr
testsuite/tests/dependent/should_fail/T14066e.stderr
testsuite/tests/dependent/should_fail/T15591b.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15591b.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15591c.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15591c.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15743c.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15743c.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15743d.hs [new file with mode: 0644]
testsuite/tests/dependent/should_fail/T15743d.stderr [new file with mode: 0644]
testsuite/tests/dependent/should_fail/all.T
testsuite/tests/ghci/scripts/T15591.hs
testsuite/tests/ghci/scripts/T15591.script
testsuite/tests/ghci/scripts/T15591.stdout
testsuite/tests/ghci/scripts/T15743b.hs [new file with mode: 0644]
testsuite/tests/ghci/scripts/T15743b.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T15743b.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/T6018ghcifail.stderr
testsuite/tests/ghci/scripts/all.T
testsuite/tests/indexed-types/should_fail/T14175.stderr
testsuite/tests/patsyn/should_compile/T14394.stdout
testsuite/tests/patsyn/should_compile/T14552.hs [moved from testsuite/tests/patsyn/should_fail/T14552.hs with 100% similarity]
testsuite/tests/patsyn/should_compile/all.T
testsuite/tests/patsyn/should_fail/T14552.stderr [deleted file]
testsuite/tests/patsyn/should_fail/all.T
testsuite/tests/polykinds/PolyKinds06.stderr
testsuite/tests/polykinds/T13625.stderr
testsuite/tests/polykinds/T14846.stderr
testsuite/tests/polykinds/T15592.hs
testsuite/tests/polykinds/T7524.stderr
testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr
testsuite/tests/typecheck/should_fail/T14350.stderr
testsuite/tests/typecheck/should_fail/T6018fail.stderr
testsuite/tests/typecheck/should_fail/T6018failclosed.stderr
testsuite/tests/typecheck/should_fail/T7892.stderr