[GHC] #11509: Incorrect error message in StandaloneDeriving: "The data constructors of <typeclass> are not all in scope"
GHC
ghc-devs at haskell.org
Fri Oct 14 17:27:41 UTC 2016
#11509: Incorrect error message in StandaloneDeriving: "The data constructors of
<typeclass> are not all in scope"
-------------------------------------+-------------------------------------
Reporter: edsko | Owner:
Type: bug | Status: patch
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version: 8.0.1-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2558
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari <ben@…>):
In [changeset:"d5a4e49d657682eeb6e86ae464d281974ce2f5e2/ghc"
d5a4e49d/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="d5a4e49d657682eeb6e86ae464d281974ce2f5e2"
Make error when deriving an instance for a typeclass less misleading
Before, when you attempted to derive an instance for a typeclass,
e.g.,
```
class C1 (a :: Constraint) where
class C2 where
deriving instance C1 C2
```
GHC would complain that `C2`'s data constructors aren't in scope. But
that
makes no sense, since typeclasses don't have constructors! By refining
the
checks that GHC performs when deriving, we can make the error message a
little more sensible.
This also cleans up a related `DeriveAnyClass` infelicity. Before, you
wouldn't have been able to compile code like this:
```
import System.IO (Handle)
class C a
deriving instance C Handle
```
Since GHC was requiring that all data constructors of `Handle` be in
scope. But `DeriveAnyClass` doesn't even generate code that mentions
any data constructors, so this requirement is silly!
Fixes #11509.
Test Plan: make test TEST=T11509
Reviewers: simonpj, austin, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie, simonpj
Differential Revision: https://phabricator.haskell.org/D2558
GHC Trac Issues: #11509
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11509#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list