Ticket #1900 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

Type families with class constraints: type-checker loops

Reported by: h.holtmann Owned by: chak
Priority: normal Milestone: 6.10 branch
Component: Compiler (Type checker) Version: 6.9
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: T1900 Blocked By:
Blocking: Related Tickets:

Description

The following program:

{-# LANGUAGE TypeFamilies, FlexibleContexts #-}

class (Eq (Depend s))=> Bug s where
  type Depend s 
  trans :: Depend s -> Depend s
  
instance Bug Int where
  type Depend Int = ()
  trans = (+1)
  
check :: (Bug s) => Depend s -> Bool
check d = d == trans d

runs into a type-checker loop

GHC-Bug.hs:1:0:
    Context reduction stack overflow; size = 20
    Use -fcontext-stack=N to increase stack size to N
        `ic :: {(Bug Int, Eq (Depend Int)) => Num ()}'
          arising from the type signature for `trans' at GHC-Bug.hs:24:2-13
        `ic :: {(Bug Int, Eq (Depend Int)) => Num ()}'
          arising from the type signature for `trans' at GHC-Bug.hs:24:2-13
    <snip>

Of course, this program should not compile, but the type-checker should not loop.

compiler: 6.9.20071105

Attachments

GHC-Bug.hs Download (262 bytes) - added by h.holtmann 6 years ago.

Change History

Changed 6 years ago by h.holtmann

Changed 6 years ago by igloo

  • owner set to chak
  • difficulty set to Unknown
  • component changed from Compiler to Compiler (Type checker)
  • milestone set to 6.10 branch

Thanks for the report. Another one for you, Manuel?

Changed 5 years ago by chak

  • status changed from new to closed
  • resolution set to fixed

Works now in the head.

Changed 5 years ago by chak

  • testcase set to T1900
Note: See TracTickets for help on using tickets.