diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-11-30 17:05:11 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-01-29 02:41:21 -0500 |
commit | 268efcc9a45da36458442d9203c66a415b48f2b3 (patch) | |
tree | 8d99c80c3ebf68cd91c4262573a1a8634863f90a /testsuite/tests/partial-sigs | |
parent | bb15c34784a3143ef048807fd351667d6775e399 (diff) | |
download | haskell-268efcc9a45da36458442d9203c66a415b48f2b3.tar.gz |
Rework the handling of SkolemInfo
The main purpose of this patch is to attach a SkolemInfo directly to
each SkolemTv. This fixes the large number of bugs which have
accumulated over the years where we failed to report errors due to
having "no skolem info" for particular type variables. Now the origin of
each type varible is stored on the type variable we can always report
accurately where it cames from.
Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946
#19760 #20063 #13499 #14040
The main changes of this patch are:
* SkolemTv now contains a SkolemInfo field which tells us how the
SkolemTv was created. Used when reporting errors.
* Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl)
to the SkolemInfo and level of the type variables in ic_skols.
* All ic_skols are TcTyVars -- Check is currently disabled
* All ic_skols are SkolemTv
* The tv_lvl of the ic_skols agrees with the ic_tclvl
* The ic_info agrees with the SkolInfo of the implication.
These invariants are checked by a debug compiler by
checkImplicationInvariants.
* Completely refactor kcCheckDeclHeader_sig which kept
doing my head in. Plus, it wasn't right because it wasn't skolemising
the binders as it decomposed the kind signature.
The new story is described in Note [kcCheckDeclHeader_sig]. The code
is considerably shorter than before (roughly 240 lines turns into 150
lines).
It still has the same awkward complexity around computing arity as
before, but that is a language design issue.
See Note [Arity inference in kcCheckDeclHeader_sig]
* I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used
them to be clear which TcTyCons have "finished" kinds etc, and
which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon]
* I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a
better name, and it is very useful in kcCheckDeclHeader_sig, where
eta-expansion isn't an issue.
* Kill off the nasty `ClassScopedTvEnv` entirely.
Co-authored-by: Simon Peyton Jones <simon.peytonjones@gmail.com>
Diffstat (limited to 'testsuite/tests/partial-sigs')
-rw-r--r-- | testsuite/tests/partial-sigs/should_compile/T12033.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/partial-sigs/should_fail/T14040a.stderr | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/testsuite/tests/partial-sigs/should_compile/T12033.stderr b/testsuite/tests/partial-sigs/should_compile/T12033.stderr index 780fb9d41b..9f9fdd6a17 100644 --- a/testsuite/tests/partial-sigs/should_compile/T12033.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T12033.stderr @@ -1,15 +1,15 @@ T12033.hs:12:22: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘v -> t’ - Where: ‘t’ is a rigid type variable bound by + Where: ‘v’ is a rigid type variable bound by + the type signature for: + tripleStoreToRuleSet :: forall v. v -> v + at T12033.hs:6:1-30 + ‘t’ is a rigid type variable bound by the inferred types of makeTuple :: v -> t makeExpression :: v -> t at T12033.hs:(11,4)-(13,39) - ‘v’ is a rigid type variable bound by - the type signature for: - tripleStoreToRuleSet :: forall v. v -> v - at T12033.hs:6:1-30 • In the type signature: makeExpression :: _ In an equation for ‘tripleStoreToRuleSet’: tripleStoreToRuleSet getAtom diff --git a/testsuite/tests/partial-sigs/should_fail/T14040a.stderr b/testsuite/tests/partial-sigs/should_fail/T14040a.stderr index 8e2d02e9b3..18f8439a7f 100644 --- a/testsuite/tests/partial-sigs/should_fail/T14040a.stderr +++ b/testsuite/tests/partial-sigs/should_fail/T14040a.stderr @@ -7,7 +7,7 @@ T14040a.hs:26:46: error: This (rigid, skolem) kind variable is bound by an explicit forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)) - at T14040a.hs:(25,19)-(27,41) + at T14040a.hs:25:26-77 • In the second argument of ‘p’, namely ‘xs’ In the type ‘Sing wl -> (forall (y :: Type). p _ WeirdNil) @@ -37,7 +37,7 @@ T14040a.hs:27:27: error: This (rigid, skolem) kind variable is bound by an explicit forall (z :: Type) (x :: z) (xs :: WeirdList (WeirdList z)) - at T14040a.hs:(25,19)-(27,41) + at T14040a.hs:25:26-77 • In the second argument of ‘p’, namely ‘(WeirdCons x xs)’ In the type ‘Sing wl -> (forall (y :: Type). p _ WeirdNil) |