Opened 2 years ago

Closed 19 months ago

#7800 closed bug (fixed)

Error message when deriving Typeable without PolyKinds

Reported by: monoidal Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: deriving/should_fail/T7800
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Module M:

{-# LANGUAGE PolyKinds #-}
module M where

data A a

Module N:

{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}
module N where

import M
import Data.Typeable

deriving instance Typeable A

We get a confusing error message:

N.hs:7:1:
    Derived typeable instance must be of form (Typeable A)
    In the stand-alone deriving instance for ‛Typeable A’

The error disappears when N is compiled with -XPolyKinds. The reason is: without -XPolyKinds, A defaults to A *. I think it's simplest to suggest the flag in the error message.

Attachments (2)

0001-Better-error-message-when-deriving-Typeable-without-.patch (2.4 KB) - added by monoidal 19 months ago.
0001-Test-for-7800.patch (2.8 KB) - added by monoidal 19 months ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 2 years ago by dreixel

  • Owner set to dreixel

I agree that this error message is confusing, thanks for reporting. I'll look into it.

comment:2 Changed 2 years ago by igloo

  • difficulty set to Unknown
  • Milestone set to 7.8.1

comment:3 Changed 19 months ago by monoidal

dreixel: I think it would be good to fix this before 7.8. Is it OK that I only edit the message to include "If you are deriving Typeable for a polykinded datatype, make sure PolyKinds is on"? This is rather blunt but it's a working solution.

comment:4 Changed 19 months ago by dreixel

Sorry, I forgot about this. And I won't have much time to look at it before ICFP. So yes, please do change the message; it's an improvement.

Changed 19 months ago by monoidal

comment:5 Changed 19 months ago by monoidal

  • Owner dreixel deleted

comment:6 Changed 19 months ago by monoidal

  • Status changed from new to patch

comment:7 Changed 19 months ago by Simon Peyton Jones <simonpj@…>

In 86033a00d6af909be1f8ac3a638529144ccc26d2/ghc:

Improve error message for deriving polykinded Typeable (Trac #7800)

Thanks to Krzysztof Gogolewski (monoidal) for the first draft of this patch

comment:8 Changed 19 months ago by Simon Peyton Jones <simonpj@…>

comment:9 Changed 19 months ago by simonpj

  • Resolution set to fixed
  • Status changed from patch to closed
  • Test Case set to deriving/should_fail/T7800
Note: See TracTickets for help on using tickets.