Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10817 closed bug (fixed)

Looping default associated type family without UndecidableInstances

Reported by: goldfire Owned by:
Priority: normal Milestone: 7.10.3
Component: Compiler (Type checker) Version: 7.10.2
Keywords: Cc: jstolarek
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: indexed-types/should_fail/T10817
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1262
Wiki Page:


When I say

{-# LANGUAGE TypeFamilies #-}

module Bug where

import Data.Proxy

class C a where
  type F a
  type F a = F a

instance C Bool

x :: Proxy (F Bool)
x = Proxy

GHC just loops. Setting a low -ftype-function-depth doesn't help. I actually don't terribly mind the looping (although aborting with an overflow would be better). But I don't like that it's possible without UndecidableInstances in sight.

Change History (9)

comment:1 Changed 4 years ago by thomie

Component: CompilerCompiler (Type checker)

comment:2 Changed 4 years ago by jstolarek

Cc: jstolarek added

comment:3 Changed 4 years ago by goldfire

Differential Rev(s): Phab:D1262
Status: newpatch

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

In e27b267/ghc:

Perform a validity check on assoc type defaults.

This fixes #10817 and #10899. A knock-on effect is that we must
now remember locations of associated type defaults for error
messages during validity checking. This isn't too bad, but it
increases the size of the diff somewhat.

Test cases: indexed-types/should_fail/T108{17,99}

comment:5 Changed 4 years ago by goldfire

Milestone: 7.10.3
Status: patchmerge
Test Case: indexed-types/should_fail/T10817

Worth merging this one.

comment:6 Changed 4 years ago by bgamari

goldfire, do you suppose you could backport this to ghc-7.10? I tried but there have been just enough differences in this area that I'm not sure I trust myself to get this right. Alternatively we could just punt. Your call.

comment:7 Changed 4 years ago by goldfire

I'll take a look at this today.

comment:8 Changed 4 years ago by goldfire

I've just pushed a patch (relative to ghc-7.10) to wip/rae. (See commit 8b69b318802f59cfeb0779779cfbbebf74348fa0.) I can't validate because of the problem Simon already mentioned about ghc-7.10 not building. But hopefully this is only a typo or two away from working.

comment:9 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed


Last edited 4 years ago by bgamari (previous) (diff)
Note: See TracTickets for help on using tickets.