Opened 5 years ago

Last modified 3 years ago

#9547 new bug

Empty constraint tuples are mis-kinded

Reported by: simonpj Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:



-- If :: forall k. 'Bool -> k -> k -> k
type family If cond tru fls where
   If True tru fls = tru
   If False tru fls = fls

foo :: If True () (Eq a) => a -> a
foo = error "urk"

This should work fine. But we get

    The third argument of `If' should have kind `*',
      but `Eq a' has kind `Constraint'
    In the type signature for `foo': foo :: If True () (Eq a) => a -> a

Reason: GHC is treating the () unit tuple as of kind *.

Reason is that in the HsTupleTy case of tc_hs_type in TcHsType, we see

         -- In the [] case, it's not clear what the kind is, so guess *

And that guess is plain wrong in this case. Unfortunately I don't see an easy fix, but it's plain wrong as-is.


Change History (2)

comment:1 Changed 4 years ago by thomie

Component: CompilerCompiler (Type checker)

comment:2 Changed 3 years ago by Iceland_jack

For the record, works if annotated:

import GHC.Exts

foo :: If True (() :: Constraint) (Eq a) => a -> a
foo = error "urk"
Note: See TracTickets for help on using tickets.