Ticket #3959 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

indenting change causes internal error

Reported by: RichardG Owned by: simonpj
Priority: low Milestone: 7.0.1
Component: Compiler Version: 6.12.1
Keywords: Cc:
Operating System: MacOS X Architecture: x86
Type of failure: None/Unknown Difficulty:
Test Case: simplCore/should_run/T3959 Blocked By:
Blocking: #3961, #3983 Related Tickets:

Description

I found a bizarre little bug in GHC 6.12.1 on Mac OS X 10.6 (Haskell Platform 2010.1.0.0 i386). It only occurs when compiling through Cabal; it does not occur when using ghc --make or ghci.

The following code will compile without error but will generate a runtime error:

test = do
       E.throw Failure
       (return "No exception" :: IO String)
     `E.catches`
      [E.Handler (\Failure -> return "Exception")]

The following code will compile and run correctly:

test = do
      E.throw Failure
       (return "No exception" :: IO String)
     `E.catches`
      [E.Handler (\Failure -> return "Exception")]

The only difference between the 2 is that the second has one less leading space.

The generated error is:

test1: internal error: PAP object entered!
    (GHC version 6.12.1 for i386_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Abort trap

Deleting my ~/.ghc folder had no effect.

Attachments

Indenting.zip Download (1.7 KB) - added by RichardG 3 years ago.
Source code and Cabal files for tests

Change History

Changed 3 years ago by RichardG

Source code and Cabal files for tests

Changed 3 years ago by RichardG

I forgot to mention that the following will compile without warning:

test = do
       E.throw Failure
       return "No exception"
     `E.catches`
      [E.Handler (\Failure -> return "Exception")]

whereas

test = do
      E.throw Failure
       return "No exception"
     `E.catches`
      [E.Handler (\Failure -> return "Exception")]

generates the following error:

Test2.hs:19:7:
    Ambiguous type variable `m' in the constraint:
      `Monad m' arising from a use of `return' at Test2.hs:19:7-12
    Probable fix: add a type signature that fixes these type variable(s)

Changed 3 years ago by igloo

Note that the two definitions are not parsed the same; if you compile with -ddump-parsed then you see

test = do { E.throw Failure;
            (return "No exception" :: IO String) }
     `E.catches`
       [E.Handler (\ Failure -> return "Exception")]

vs

test = do { E.throw Failure (return "No exception" :: IO String) }
     `E.catches`
       [E.Handler (\ Failure -> return "Exception")]

I can reproduce this on amd64/Linux with 6.12.1 and the 6.12 branch, but not the HEAD.

Changed 3 years ago by igloo

To clarify: I can reproduce the "internal error: PAP object entered!". The different parses are correct.

Changed 3 years ago by igloo

  • milestone set to 6.12.3

Changed 3 years ago by simonpj

Turns out this is #2861 in another guise. I need to think about it.

Simon

Changed 3 years ago by simonpj

See alss #3961, #3983

Simon

Changed 3 years ago by igloo

  • owner set to simonpj

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by igloo

  • blocking 3983 added

Changed 3 years ago by igloo

  • blocking 3961 added

Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to simplCore/should_run/T3959
  • resolution set to fixed

OK I think I have finally fixed this. It's all to do with eta expansion and bottoming functions; there are lots of notes in CoreArity

Fri Aug 13 17:11:51 BST 2010  simonpj@microsoft.com
  * Re-do the arity calculation mechanism again (fix Trac #3959)
  
  After rumination, yet again, on the subject of arity calculation,
  I have redone what an ArityType is (it's purely internal to the
  CoreArity module), and documented it better.  The result should
  fix #3959, and I hope the related #3961, #3983.
  
  There is lots of new documentation: in particular
   * Note [ArityType]  
     describes the new datatype for arity info
  
   * Note [State hack and bottoming functions] 
     says how bottoming functions are dealt with, particularly
     covering catch# and Trac #3959
  
  I also found I had to be careful not to eta-expand single-method
  class constructors; see Note [Newtype classes and eta expansion].
  I think this part could be done better, but it works ok.

Simon

Note: See TracTickets for help on using tickets.