Ticket #1795 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

typechecker loops on simple program with fundep

Reported by: guest Owned by: simonpj
Priority: normal Milestone: 6.8.1
Component: Compiler Version: 6.8
Keywords: Cc: ganesh.sittampalam@…
Operating System: Unknown/Multiple Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: FD3 Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj) (diff)

The program below causes the "Renamer/typechecker" phase to loop. Confirmed with GHC 6.8.20070927 on Linux and 6.9.20071018 on Windows (so I'm not absolutely certain it's present in latest 6.8, but it seems very likely).

The program has an infinite type - the definition of translate causes (String, a) to be unified with a. Removing the fundep in MkA causes a reasonable error to be reported.

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}
module X() where

data A a = A

class MkA a b | a -> b where
   mkA :: a -> A b

instance MkA a a where

translate :: (String, a) -> A a
translate a = mkA a

Ganesh

PS: See also #1797 and #1781

Change History

Changed 6 years ago by igloo

  • milestone set to 6.8.1

This also happens with my 6.8.0.20071019, and is a regression since 6.6.

Changed 6 years ago by simonmar

  • owner set to simonpj

Changed 6 years ago by simonpj

  • description modified (diff)

Definitely a bug. It happens because the improvement gives rise to an equality (a ~ (String,a)), and this equality is simply generated but not discharged, by TcSimplify.tcImprove.

Simon

Changed 6 years ago by simonpj

  • testcase changed from yes to FD3

Changed 6 years ago by simonpj

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

Fixed! The error message is different than before:

FD3.hs:22:14:
    Could not deduce (MkA (String, a) a) from the context ()
      arising from a use of `mkA' at FD3.hs:22:14-18

but it's still reasonable.

Patch is this one:

Sat Oct 27 16:54:59 GMT Daylight Time 2007  simonpj@microsoft.com
  * Make 'improvement' work properly in TcSimplify

Thanks Ganesh!

Changed 5 years ago by simonmar

  • os changed from Multiple to Unknown/Multiple
Note: See TracTickets for help on using tickets.