Opened 5 years ago

Last modified 4 years ago

#9235 new bug

Simplifier ticks exhausted on recursive class method

Reported by: klao Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


GHC 7.8 and HEAD panic on the following code:

module C where

class C a where
  c :: C a => a -> Int
  c a = c a
  {-# INLINE c #-}

instance C ()

x :: Int
x = c ()

Note that it's the coincidence of the 3 conditions that triggers this bug:

  1. the c method has to be inlined (explicity or implicitly)
  2. it has to be recursive (but, it doesn't have to be as dumbly recursive as in the example)
  3. it has to have this weird, slightly mistaken type signature: C a => a -> Int instead of simply a -> Int.

But, when this incidentally happens (in my case, both 2. and 3. were unintentional), the user gets a very hard to debug issue. They don't even get an indication which module is responsible if c is used from a different module than the one with the class definition.

Also note that this happens even with a non-optimized build. And in this example c has to be explicitly marked NOINLINE to prevent it. (In the instance that I caught in the wild simply removing the INLINE annotation was enough.)

Finally, on a side note: shouldn't 3. by itself be an error? Or a warning at least?

Change History (2)

comment:1 Changed 5 years ago by simonpj

This is a dup of #5722, but I'm going to leave it open as evidence that someone else has tripped up over it.

The weird type signature is a special case of something that is generally allowed. I don't in general know how to stop it.


comment:2 Changed 4 years ago by thomie

Note: See TracTickets for help on using tickets.