summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-04-03 10:28:15 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-04-04 08:12:28 -0400
commit33b0a291898b6a35d822fde59864c5c94a53d039 (patch)
treeb3510a976cd5e2685b929bc4f0b573c6f84ae64c /compiler/codeGen
parentcbb8886560e63b662f50965cc96efafa8dd6875a (diff)
downloadhaskell-33b0a291898b6a35d822fde59864c5c94a53d039.tar.gz
Tweak error messages for narrowly-kinded assoc default decls
This program, from #13971, currently has a rather confusing error message: ```hs class C a where type T a :: k type T a = Int ``` ``` • Kind mis-match on LHS of default declaration for ‘T’ • In the default type instance declaration for ‘T’ In the class declaration for ‘C’ ``` It's not at all obvious why GHC is complaining about the LHS until you realize that the default, when printed with `-fprint-explicit-kinds`, is actually `type T @{k} @* a = Int`. That is to say, the kind of `a` is being instantiated to `Type`, whereas it ought to be a kind variable. The primary thrust of this patch is to weak the error message to make this connection more obvious: ``` • Illegal argument ‘*’ in: ‘type T @{k} @* a = Int’ The arguments to ‘T’ must all be type variables • In the default type instance declaration for ‘T’ In the class declaration for ‘C’ ``` Along the way, I performed some code cleanup suggested by @rae in https://gitlab.haskell.org/ghc/ghc/issues/13971#note_191287. Before, we were creating a substitution from the default declaration's type variables to the type family tycon's type variables by way of `tcMatchTys`. But this is overkill, since we already know (from the aforementioned validity checking) that all the arguments in a default declaration must be type variables anyway. Therefore, creating the substitution is as simple as using `zipTvSubst`. I took the opportunity to perform this refactoring while I was in town. Fixes #13971.
Diffstat (limited to 'compiler/codeGen')
0 files changed, 0 insertions, 0 deletions