Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#9167 closed bug (fixed)

Associated type is accepted even without mentioning class parameters

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


The following module is accepted:

{-# LANGUAGE TypeFamilies #-}

module Bug where

class C a where
  type F b

Note that the associate type family F does not mention the class variable a. Because associated type families are somewhat thin sugar over non-associated type families, I doubt this causes any great disaster anywhere, but it should probably be fixed.

Change History (5)

comment:1 Changed 3 years ago by archblob

This is not 7.8.2 specific, it originated in 7.4.1.

comment:2 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In 66bddbb27fd9c383f85005b8c6e1961d25d7a7dd/ghc:

Check that an associated type mentions at least one type variable from the class

Fixes Trac #9167

comment:3 Changed 3 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: indexed_types/should_fail/T9167

Good point. Done.


comment:4 Changed 3 years ago by archblob

The error message now says

The associated type ‘F’
    mentions none of the type variables of the class ‘C k a’
    In the class declaration for ‘C’


class C (a :: k) where
  type F (b :: k)

is accepted although none of the class type variables are mentioned in the definition for F . If this is the intended behavior maybe the error message should say type or kind variables.

comment:5 Changed 3 years ago by Richard Eisenberg <eir@…>

In 1153194ca1ec867ca01675a902cdf7dab72b5dab/ghc:

Clarify error message. See #9167.
Note: See TracTickets for help on using tickets.