Opened 3 years ago

Last modified 20 months ago

#13011 new bug

Simplifier ticks exhausted: a 10-line case

Reported by: L.K.Rebellion Owned by:
Priority: lowest Milestone:
Component: Compiler Version: 8.0.1
Keywords: Simplifier ticks exhausted Cc:
Operating System: Linux Architecture: x86
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: #8319 #12776 Differential Rev(s):
Wiki Page:

Description

I was trying to define a function that could take itself as an argument.

newtype MobiusFn a = MobiusFn {
    func :: MobiusFn a -> a
}

spin :: MobiusFn a -> a
spin mf = func mf mf

Use it to find suffixes of a String

suffixes :: String -> [String]
suffixes = spin $ MobiusFn suffixesMF
    where suffixesMF _ [] = []
          suffixesMF mf s@(_:xs) = s : spin mf xs

Add main and compile

main = readLn >>= (print . suffixes)

The compiler panicked with

[1 of 1] Compiling Main             ( test.hs, test.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.0.1 for i386-unknown-linux):
        Simplifier ticks exhausted
  When trying UnfoldingDone mf_s1UD

But if we ignore the empty string case, it works well with non-empty strings.

suffixes :: String -> [String]
suffixes = spin $ MobiusFn suffixesMF
    where suffixesMF _ s@[_] = [s]
          suffixesMF mf s@(_:xs) = s : spin mf xs

Two versions tested.

GHC version 8.0.1 for i386-unknown-linux
GHC version 7.10.3 for i386-unknown-linux

Thank you for reading.

Change History (3)

comment:1 Changed 3 years ago by simonpj

comment:2 Changed 20 months ago by George

Given Simon's comment above and the doc that seems to say this will never be fixed does it make sense to leave this as high priority?

Note also that the error message says:

If GHC was unable to complete compilation even with a very large factor (a thousand or more), please consult the "Known bugs or infelicities" section in the Users Guide before filing a report. There are a few situations unlikely to occur in practical programs for which simplifier non-termination has been judged acceptable.

comment:3 Changed 20 months ago by L.K.Rebellion

Priority: highlowest
Note: See TracTickets for help on using tickets.