From d5a4e49d657682eeb6e86ae464d281974ce2f5e2 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Fri, 14 Oct 2016 10:40:56 -0400 Subject: 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 --- testsuite/tests/deriving/should_fail/all.T | 2 ++ 1 file changed, 2 insertions(+) (limited to 'testsuite/tests/deriving/should_fail/all.T') diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T index ce0cc0f155..5fec71eff5 100644 --- a/testsuite/tests/deriving/should_fail/all.T +++ b/testsuite/tests/deriving/should_fail/all.T @@ -64,5 +64,7 @@ test('T10598_fail3', normal, compile_fail, ['']) test('T10598_fail4', normal, compile_fail, ['']) test('T10598_fail5', normal, compile_fail, ['']) test('T10598_fail6', normal, compile_fail, ['']) +test('T11509_1', [when(doing_ghci(), extra_hc_opts('-fobject-code'))], + compile_fail, ['']) test('T12163', normal, compile_fail, ['']) test('T12512', omit_ways(['ghci']), compile_fail, ['']) -- cgit v1.2.1