Opened 7 years ago

Closed 7 years ago

Last modified 3 months ago

#4309 closed bug (fixed)

Painfully large errors with silly GADT instances

Reported by: pumpkin Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.12.3
Keywords: deriving Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: deriving/should_fail/drvfail011
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


If (for whatever reason) you decide to ask GHC to derive (using StandaloneDeriving) silly instances for GADTs, like maybe Ord on a GADT that refines its parameters to incompatible types for different constructors, the automatic deriving mechanism fails with massive errors. The attached file gives me 301 lines of errors in GHCi, as it seems to print all the generated code, and the generated code increases in size with the number of constructors of the datatype. I have a large GADT in a project of mine with a couple hundred constructors, and it gave me over 8000 lines of errors.

Attachments (1)

Ouch.hs (264 bytes) - added by pumpkin 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by pumpkin

Attachment: Ouch.hs added

comment:1 Changed 7 years ago by simonpj

The difficulty is that the alterantive is to print nothing! Which, if you have a type error, is equally uninformative. What would you like?


comment:2 Changed 7 years ago by pumpkin

It seems reasonable to me to just say "we couldn't figure out an automatically derived instance for Ord, so you'll have to write your own, sorry!"

comment:3 Changed 7 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: deriving/should_fail/drvfail011

OK, done

Wed Sep 15 00:23:01 PDT 2010
  * Less voluminous error when derived code doesn't typecheck

    M ./compiler/typecheck/TcInstDcls.lhs -8 +12

The error message now looks like:

    No instance for (Eq a)
      arising from a use of `=='
    In the expression: ((a1 == b1))
    In an equation for `==': == (T1 a1) (T1 b1) = ((a1 == b1))
    When typechecking the code for  `=='
      in a standalone derived instance for `Eq (T a)':
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for `Eq (T a)'

comment:4 Changed 3 months ago by RyanGlScott

Keywords: deriving added
Note: See TracTickets for help on using tickets.