Ticket #4358 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

infinite loop on unification with a type family context

Reported by: patrick_premont Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.1
Keywords: infinite loop type family context Cc:
Operating System: Windows Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Difficulty:
Test Case: indexed-types/should_compile/T4358 Blocked By:
Blocking: Related Tickets:

Description

The following throws ghc (and ghci) in a loop (ghc-7.0.0.20100925 for i386-unknown-mingw32) and it eventually aborts with "ghc.exe: out of memory".

> {-# LANGUAGE TypeFamilies, Rank2Types, FlexibleContexts #-}

> type family T a

> t2 :: forall a. ((T a ~ a) => a) -> a
> t2 = t
  
> t :: forall a. ((T a ~ a) => a) -> a
> t = undefined

Using ghc 6.12.1 we do not get a loop, but a puzzling error:

typeBug.lhs:9:7:

Couldn't match expected type `(T a ~ a) => a'

against inferred type `(T a ~ a) => a'

Expected type: (T a ~ a) => a Inferred type: (T a ~ a) => a

In the expression: t In the definition of `t2': t2 = t

I presume that the non-injectivity of type family T triggers the problem however the following produces no errors in either version of the compiler.

> ok2 :: forall a. T a -> a
> ok2 = ok
  
> ok :: forall a. T a -> a
> ok = undefined

Attachments

typeBug.lhs Download (0.9 KB) - added by patrick_premont 3 years ago.
Code for the bug report

Change History

Changed 3 years ago by patrick_premont

Code for the bug report

Changed 3 years ago by patrick_premont

  • version changed from 6.12.1 to 7.1

Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to indexed-types/should_compile/T4358
  • resolution set to fixed

Thanks for the example. This seems comprehensively fixed by the latest wave of typechecker fixes.

I've added a regression test though!

Simon

Note: See TracTickets for help on using tickets.