Ticket #3965 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

'deriving Data' compilation regression 6.10.1 -> 6.12.1

Reported by: ronwalf Owned by:
Priority: high Milestone: 6.12.3
Component: Compiler Version: 6.12.1
Keywords: Cc:
Operating System: MacOS X Architecture: x86
Type of failure: GHC rejects valid program Difficulty:
Test Case: deriving/should_compile/T3965 Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

Compiling the attached file in GHC 6.12.1 gives the following error, when GHC 6.10.1 compiles it fine:

[1 of 1] Compiling Main             ( baddata.hs, baddata.o )

baddata.hs:33:14:
    No instances for (Data Const, Data Var)
      arising from the 'deriving' clause of a data type declaration
                   at baddata.hs:33:14-17
    Possible fix:
      add an instance declaration for (Data Const, Data Var)
      or use a standalone 'deriving instance' declaration instead,
         so you can specify the instance context yourself
    When deriving the instance for (Data (Domain e g))

Attachments

baddata.hs Download (1.0 KB) - added by ronwalf 3 years ago.
baddata2.hs Download (1.1 KB) - added by ronwalf 3 years ago.
Simpler version, different error

Change History

Changed 3 years ago by ronwalf

Changed 3 years ago by igloo

  • description modified (diff)

Changed 3 years ago by ronwalf

baddata2.hs gives a different, possibly more informative error:

baddata2.hs:34:0:
    No instances for (Data Const, Data Var)
      arising from a use of `k' at baddata2.hs:34:0-28
    Possible fix:
      add an instance declaration for (Data Const, Data Var)
    In the expression: k (z Domain)
    In the definition of `gunfold': gunfold k z _ = k (z Domain)
    When typechecking a standalone-derived method for `Data Domain':
      gunfold k z _ = k (z Domain)
    In the instance declaration for `Data Domain'

Changed 3 years ago by ronwalf

Simpler version, different error

Changed 3 years ago by igloo

  • priority changed from normal to high
  • milestone set to 6.12.3

Great testcase, thanks!

Changed 3 years ago by simonpj

  • status changed from new to merge
  • testcase set to deriving/should_compile/T3965

Great report, thanks. Fixed by

Fri Apr  9 19:44:20 BST 2010  simonpj@microsoft.com
  * Fix Trac #3965: tighten conditions when deriving Data
  
  It's tricky to set up the context for a Data instance.  I got it wrong
  once, and fixed it -- hence the "extra_constraints" in
  TcDeriv.inferConstraints.  
  
  But it still wasn't right!  The tricky bit is that dataCast1 is only
  generated when T :: *->*, and dataCast2 when T :: *->*->*. (See
  the code in TcGenDeriv for dataCastX.

    M ./compiler/typecheck/TcDeriv.lhs -8 +14

Perhaps merge to 6.12.3

Simon

Changed 3 years ago by igloo

  • status changed from merge to closed
  • resolution set to fixed

Merged

Note: See TracTickets for help on using tickets.