Skip to content

Core Lint error with -fdefer-type-errors and kind error

The following program fails ghc -dcore-lint -fdefer-type-errors

{-# LANGUAGE TypeFamilies #-}
module M where

import Data.Kind

type F :: Type
type family F

type G :: F
type family G

x :: G
x = ()
*** Core Lint errors : in result of Desugar (before optimization) ***
<no location info>: warning:
    Non-CoVar has coercion type co_awK :: F ~# *
    Substitution: <InScope = {}
                   IdSubst   = []
                   TvSubst   = []
                   CvSubst   = []>
*** Offending Program ***
Rec {
co_awK :: F ~# *
[LclId[CoVarId]]
co_awK
  = case typeError
           @LiftedRep
           @()
           "M.hs:12:6: error: [GHC-83865]\n\
           \    \\226\\128\\162 Expected a type, but \\226\\128\\152G\\226\\128\\153 has kind \\226\\128\\152F\\226\\128\\153\n\
           \    \\226\\128\\162 In the type signature: x :: G\n\
           \(deferred type error)"#
    of wild_00 {
    }

$trModule :: Module
[LclIdX]
$trModule = Module (TrNameS "main"#) (TrNameS "M"#)

x :: (G |> co_awK)
[LclIdX]
x = case case typeError
                @LiftedRep
                @()
                "M.hs:13:5: error: [GHC-18872]\n\
                \    \\226\\128\\162 Couldn't match kind \\226\\128\\152F\\226\\128\\153 with \\226\\128\\152*\\226\\128\\153\n\
                \      When matching types\n\
                \        G :: F\n\
                \        () :: *\n\
                \    \\226\\128\\162 In the expression: ()\n\
                \      In an equation for \\226\\128\\152x\\226\\128\\153: x = ()\n\
                \(deferred type error)"#
         of wild_00 {
         }
    of co_ayG
    { __DEFAULT ->
    case case typeError
                @LiftedRep
                @()
                "M.hs:13:5: error: [GHC-18872]\n\
                \    \\226\\128\\162 Couldn't match kind \\226\\128\\152F\\226\\128\\153 with \\226\\128\\152*\\226\\128\\153\n\
                \      When matching types\n\
                \        G :: F\n\
                \        () :: *\n\
                \    \\226\\128\\162 In the expression: ()\n\
                \      In an equation for \\226\\128\\152x\\226\\128\\153: x = ()\n\
                \(deferred type error)"#
         of wild_00 {
         }
    of co_ayH
    { __DEFAULT ->
    ()
    `cast` (Sub (Sym (co_ayH
                      ; Sym (GRefl nominal () (Sym co_ayG)))
                 ; GRefl nominal G co_awK)
            :: () ~R# (G |> co_awK))
    }
    }
end Rec }
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information