diff options
author | Xavier Denis <xldenis@gmail.com> | 2020-05-03 12:34:00 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-28 16:24:37 -0400 |
commit | dc5f004c4dc27d78d3415adc54e9b6694b865145 (patch) | |
tree | 572288fe0c53dff1e913004c5a363989fb638222 /testsuite | |
parent | 5f621a78217237a4bdfb299b68827da6cc8f357e (diff) | |
download | haskell-dc5f004c4dc27d78d3415adc54e9b6694b865145.tar.gz |
Fix #18071
Run the core linter on candidate instances to ensure they are
well-kinded.
Better handle quantified constraints by using a CtWanted to avoid
having unsolved constraints thrown away at the end by the solver.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/ghci/T18071/T18071.hs | 32 | ||||
-rw-r--r-- | testsuite/tests/ghci/T18071/T18071.script | 8 | ||||
-rw-r--r-- | testsuite/tests/ghci/T18071/T18071.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghci/T18071/all.T | 1 |
4 files changed, 42 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/T18071/T18071.hs b/testsuite/tests/ghci/T18071/T18071.hs new file mode 100644 index 0000000000..1b0d53c337 --- /dev/null +++ b/testsuite/tests/ghci/T18071/T18071.hs @@ -0,0 +1,32 @@ +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DataKinds #-} +module Bug where + +import Data.Kind +import Data.Proxy + +class MyShow a where + show :: a -> String + +class (forall (z :: k). MyShow (Proxy z)) => MyShowProxy (k :: Type) where +instance (forall (z :: k). MyShow (Proxy z)) => MyShowProxy (k :: Type) + +data T :: Type -> Type + +data U = A | B + +instance forall (z :: U). MyShow (Proxy (z :: U)) where + show _ = "U" + +data U2 = A2 | B2 + +instance MyShow (Proxy A2) where + show _ = "A2" + +instance MyShow (Proxy B2) where + show _ = "B2" + diff --git a/testsuite/tests/ghci/T18071/T18071.script b/testsuite/tests/ghci/T18071/T18071.script new file mode 100644 index 0000000000..1727f26acc --- /dev/null +++ b/testsuite/tests/ghci/T18071/T18071.script @@ -0,0 +1,8 @@ +:set -Wno-simplifiable-class-constraints +:load T18071.hs +-- Should report no instances since it is ill-kinded for T +:instances T +-- U should report a match for ShowProxy +:instances U +-- U2 should not report a match for ShowProxy +:instances U2 diff --git a/testsuite/tests/ghci/T18071/T18071.stdout b/testsuite/tests/ghci/T18071/T18071.stdout new file mode 100644 index 0000000000..815aa1e245 --- /dev/null +++ b/testsuite/tests/ghci/T18071/T18071.stdout @@ -0,0 +1 @@ +instance [safe] MyShowProxy U -- Defined at T18071.hs:16:10 diff --git a/testsuite/tests/ghci/T18071/all.T b/testsuite/tests/ghci/T18071/all.T new file mode 100644 index 0000000000..9eef5bd165 --- /dev/null +++ b/testsuite/tests/ghci/T18071/all.T @@ -0,0 +1 @@ +test('T18071', [extra_files(['T18071.hs'])], ghci_script, ['T18071.script']) |