Skip to content

GHC hangs on duplicated associated type declaration

Summary

When an associated type is declared twice in a certain way, GHC seems to loop infinitely on outputting the error message.

Steps to reproduce

I was trying to get a default associated type. I now know this is not the way to do it, but a minimal example of what I tried:

{-# Language TypeFamilies #-}

module MonadElem where

class MonadElem m where
  type Elem m
  type Elem (t n) = Elem n

The original version of this managed to output the error message

<path>/MonadElem.hs:172:3: error:
    • Illegal argument

before hanging. This minimal example doesn't even get that far:

MonadElem.hs:7:3: error:

I suppose I don't know that it never returns, but I waited two minutes before ^Cing.

Expected behavior

GHC should print the appropriate error message and halt execution.

Environment

  • GHC version used: 8.10.7 (Stackage lts-18.9)
Edited by gilgamec
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information