From 1a911f217a18c8c0362ab2bf2b6ec7f7da015622 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Wed, 31 Jan 2018 21:36:51 -0500 Subject: Sequester deriving-related validity check into cond_stdOK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, any standalone-derived instance must satisfy the property that the tycon of the data type having an instance being derived for it must be either a normal ADT tycon or a data family tycon. But there are several other primitive tycons—such as `(->)`, `Int#`, and others—which cannot have standalone-derived instances (via the `anyclass` strategy) as a result of this check! See https://ghc.haskell.org/trac/ghc/ticket/13154#comment:8 for an example of where this overly conservative restriction bites. Really, this validity check only makes sense in the context of `stock` deriving, where we need the property that the tycon is that of a normal ADT or a data family in order to inspect its data constructors. Other deriving strategies don't require this validity check, so the most sensible way to fix this error is to move the logic of this check into `cond_stdOK`, which is specific to `stock` deriving. This makes progress towards fixing (but does not entirely fix) Test Plan: make test TEST=T13154a Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #13154 Differential Revision: https://phabricator.haskell.org/D4337 --- testsuite/tests/deriving/should_compile/T13154a.hs | 14 ++++++++++++++ testsuite/tests/deriving/should_compile/all.T | 1 + 2 files changed, 15 insertions(+) create mode 100644 testsuite/tests/deriving/should_compile/T13154a.hs (limited to 'testsuite/tests/deriving') diff --git a/testsuite/tests/deriving/should_compile/T13154a.hs b/testsuite/tests/deriving/should_compile/T13154a.hs new file mode 100644 index 0000000000..4d60785eb2 --- /dev/null +++ b/testsuite/tests/deriving/should_compile/T13154a.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE StandaloneDeriving #-} +module T13154a where + +import GHC.Exts + +class C1 a +deriving instance C1 (a -> b) + +class C2 (a :: TYPE 'IntRep) +deriving instance C2 Int# diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index 3360c81850..a06cd27c84 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -85,6 +85,7 @@ test('T12594', normal, compile, ['']) test('T12616', normal, compile, ['']) test('T12688', normal, compile, ['']) test('T12814', normal, compile, ['-Wredundant-constraints']) +test('T13154a', normal, compile, ['']) test('T13272', normal, compile, ['']) test('T13272a', normal, compile, ['']) test('T13297', normal, compile, ['']) -- cgit v1.2.1