summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_fail/T14339.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/deriving/should_fail/T14339.hs')
-rw-r--r--testsuite/tests/deriving/should_fail/T14339.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_fail/T14339.hs b/testsuite/tests/deriving/should_fail/T14339.hs
new file mode 100644
index 0000000000..b48f2e2501
--- /dev/null
+++ b/testsuite/tests/deriving/should_fail/T14339.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE UndecidableInstances #-}
+module Bug where
+
+import GHC.TypeLits
+
+newtype Foo = Foo Int
+
+class Bar a where
+ bar :: a
+
+instance (TypeError (Text "Boo")) => Bar Foo where
+ bar = undefined
+
+newtype Baz = Baz Foo
+ deriving Bar
+
+-- We derive:
+--
+-- instance TypeError (Text "Boo") => Bar Baz
+--
+-- And error out due to the TypeError. See also
+-- deriving/should_compile/T22696a, which uses StandaloneDeriving to write a
+-- valid instance with a TypeError constraint in its instance context.