summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_compile
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-01-31 21:36:51 -0500
committerBen Gamari <ben@smart-cactus.org>2018-01-31 23:29:30 -0500
commit1a911f217a18c8c0362ab2bf2b6ec7f7da015622 (patch)
tree3fc5a47c58ed231880286fa2e0fd351155036124 /testsuite/tests/deriving/should_compile
parentbe84823b956f0aa09c58d94d1901f2dff13546b4 (diff)
downloadhaskell-1a911f217a18c8c0362ab2bf2b6ec7f7da015622.tar.gz
Sequester deriving-related validity check into cond_stdOK
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
Diffstat (limited to 'testsuite/tests/deriving/should_compile')
-rw-r--r--testsuite/tests/deriving/should_compile/T13154a.hs14
-rw-r--r--testsuite/tests/deriving/should_compile/all.T1
2 files changed, 15 insertions, 0 deletions
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, [''])