Opened 4 years ago

Closed 4 years 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: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: deriving/should_fail/drvfail011 Blocked By:
Blocking: Related Tickets:

Description

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 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by pumpkin

comment:1 Changed 4 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?

Simon

comment:2 Changed 4 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 4 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to deriving/should_fail/drvfail011

OK, done

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

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

The error message now looks like:

drvfail011.hs:8:1:
    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)'
Note: See TracTickets for help on using tickets.