diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-05-26 06:58:20 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-10 03:39:12 -0400 |
commit | a47e6442bc4be4a33339499d876792ba109e8d32 (patch) | |
tree | b2475e4d0c234c8318635bdfb4a74f49223fb72b /testsuite/tests/polykinds | |
parent | 72c7fe9a1e147dfeaf043f6d591d724a126cce45 (diff) | |
download | haskell-a47e6442bc4be4a33339499d876792ba109e8d32.tar.gz |
Always use rnImplicitBndrs to bring implicit tyvars into scope
This implements a first step towards #16762 by changing the renamer
to always use `rnImplicitBndrs` to bring implicitly bound type
variables into scope. The main change is in `rnFamInstEqn` and
`bindHsQTyVars`, which previously used _ad hoc_ methods of binding
their implicit tyvars.
There are a number of knock-on consequences:
* One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding
mechanism was to give more precise source locations in
`-Wunused-type-patterns` warnings. (See
https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an
example of this.) However, these warnings are actually a little
_too_ precise, since implicitly bound type variables don't have
exact binding sites like explicitly bound type variables do.
A similar problem existed for
"`Different names for the same type variable`" errors involving
implicit tyvars bound by `bindHsQTyVars`.
Therefore, we simply accept the less precise (but more accurate)
source locations from `rnImplicitBndrs` in `rnFamInstEqn` and
`bindHsQTyVars`. See
`Note [Source locations for implicitly bound type variables]` in
`GHC.Rename.HsType` for the full story.
* In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs
to be able to look up names from the parent class (in the event
that we are renaming an associated type family instance). As a
result, `rnImplicitBndrs` now takes an argument of type
`Maybe assoc`, which is `Just` in the event that a type family
instance is associated with a class.
* Previously, GHC kept track of three type synonyms for free type
variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups`
(which are allowed to contain duplicates), and
`FreeKiTyVarsNoDups` (which contain no duplicates). However, making
is a distinction between `-Dups` and `-NoDups` is now pointless, as
all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually
end up being passed to `rnImplicitBndrs`, which removes duplicates.
As a result, I decided to just get rid of `FreeKiTyVarsDups` and
`FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`.
* The `bindLRdrNames` and `deleteBys` functions are now dead code, so
I took the liberty of removing them.
Diffstat (limited to 'testsuite/tests/polykinds')
-rw-r--r-- | testsuite/tests/polykinds/T11203.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T11821a.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T17841.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T7224.stderr | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/testsuite/tests/polykinds/T11203.stderr b/testsuite/tests/polykinds/T11203.stderr index e6f30c0335..decefbd1fa 100644 --- a/testsuite/tests/polykinds/T11203.stderr +++ b/testsuite/tests/polykinds/T11203.stderr @@ -1,4 +1,4 @@ -T11203.hs:7:24: error: +T11203.hs:7:9: error: • Different names for the same type variable: ‘k1’ and ‘k2’ • In the data declaration for ‘Q’ diff --git a/testsuite/tests/polykinds/T11821a.stderr b/testsuite/tests/polykinds/T11821a.stderr index 50d58df8f5..cc18f2c0fd 100644 --- a/testsuite/tests/polykinds/T11821a.stderr +++ b/testsuite/tests/polykinds/T11821a.stderr @@ -1,4 +1,4 @@ -T11821a.hs:4:31: error: +T11821a.hs:4:16: error: • Different names for the same type variable: ‘k1’ and ‘k2’ • In the type declaration for ‘SameKind’ diff --git a/testsuite/tests/polykinds/T17841.stderr b/testsuite/tests/polykinds/T17841.stderr index 11243a4322..de33036dcf 100644 --- a/testsuite/tests/polykinds/T17841.stderr +++ b/testsuite/tests/polykinds/T17841.stderr @@ -3,7 +3,7 @@ T17841.hs:7:45: error: • Expected a type, but ‘t’ has kind ‘k2’ ‘k2’ is a rigid type variable bound by the class declaration for ‘Foo’ - at T17841.hs:7:17 + at T17841.hs:7:12-17 • In the kind ‘t’ In the first argument of ‘Proxy’, namely ‘(a :: t)’ In the type signature: foo :: Proxy (a :: t) diff --git a/testsuite/tests/polykinds/T7224.stderr b/testsuite/tests/polykinds/T7224.stderr index c9d2236206..ca1f32c1c2 100644 --- a/testsuite/tests/polykinds/T7224.stderr +++ b/testsuite/tests/polykinds/T7224.stderr @@ -3,7 +3,7 @@ T7224.hs:6:19: error: • Expected kind ‘i’, but ‘i’ has kind ‘*’ ‘i’ is a rigid type variable bound by the class declaration for ‘PMonad'’ - at T7224.hs:5:21 + at T7224.hs:5:16-36 • In the first argument of ‘m’, namely ‘i’ In the type signature: ret' :: a -> m i i a In the class declaration for ‘PMonad'’ @@ -12,7 +12,7 @@ T7224.hs:7:14: error: • Expected kind ‘i’, but ‘i’ has kind ‘*’ ‘i’ is a rigid type variable bound by the class declaration for ‘PMonad'’ - at T7224.hs:5:21 + at T7224.hs:5:16-36 • In the first argument of ‘m’, namely ‘i’ In the type signature: bind' :: m i j a -> (a -> m j k b) -> m i k b |