Skip to content

GHC internal error in class; "not in scope during type checking, but passed to the renamer"

Summary

I was working with standaloneKindSignatures and using visible dependent quantification in a class. The error said

  GHC internal error: f is not in scope during type checking, but it passed the renamer
      tcl_env of environment: [aG5 :-> Type variable k = k :: *,
                               aG6 :-> Type variable oo = oo :: *,
                               aG7 :-> Type variable mm = mm :: k -> *,
                               aG9 :-> Type variable u = u :: *,
                               aGa :-> Type variable a = a :: mm u,
                               aGb :-> Type variable d = d :: k,
                               aGd :-> Type variable u = u :: k,
                               aGh :-> Type variable k = k :: *,
                               rG3 :-> ATcTyCon UF :: forall {k} (u :: k).
                                                      *
                                                      -> forall (mm :: k -> *) k1 ->
                                                         * -> mm u -> k1 -> Constraint,
                               rG4 :-> ATcTyCon FF :: forall {k} {mm :: k -> *} {u1 :: k}
                                                             (f :: * -> *) u2.
                                                      mm u1 -> f u2]
     In the kind f u
      In the first argument of FF, namely (a :: f u)
      In the first argument of (~~), namely (FF (a :: f u))
   |
11 | class (((FF (a::f u) ) ~~ (a::k))) =>UF oo mm (f) (u) (a) (d::k) where
   |                 ^^^

Steps to reproduce

compile this code

import Data.Kind (Type)
import Data.Type.Equality
import GHC.Exts (Constraint)




type UF ::  Type -> forall f -> forall k -> Type -> f u -> k -> Constraint
class (((FF (a::f u) ) ~~ (a::k))) =>UF oo mm (f) (u) (a) (d::k) where
  type FF a = (c:: f u) | c -> f u

Expected behavior

result in a more informative error message or not error.

Environment

GHC 9.8.2

Edited by Jkensik
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information