Opened 12 months ago

Closed 12 months ago

Last modified 12 months 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 Revisions:

Description

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 12 months ago by archblob

This is not 7.8.2 specific, it originated in 7.4.1.

comment:2 Changed 12 months 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 12 months ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to indexed_types/should_fail/T9167

Good point. Done.

Simon

comment:4 Changed 12 months 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’

but

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 12 months ago by Richard Eisenberg <eir@…>

In 1153194ca1ec867ca01675a902cdf7dab72b5dab/ghc:

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