diff options
author | Xavier Denis <xldenis@gmail.com> | 2020-06-15 11:37:16 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-23 22:48:56 -0400 |
commit | a2a9006b068ba9af9d41711307a8d597d2bb03d7 (patch) | |
tree | 1db6f5afc2eac3ceac844c6a9613be3990911a26 /testsuite | |
parent | cad62ef11972490b180fad3cd4a5c7754fa218e4 (diff) | |
download | haskell-a2a9006b068ba9af9d41711307a8d597d2bb03d7.tar.gz |
Fix issue #18262 by zonking constraints after solving
Zonk residual constraints in checkForExistence to reveal user type
errors.
Previously when `:instances` was used with instances that have TypeError
constraints the result would look something like:
instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10
whereas after zonking, `:instances` now sees the `TypeError` and
properly eliminates the constraint from the results.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/ghci/T18262/T18262.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/ghci/T18262/T18262.script | 6 | ||||
-rw-r--r-- | testsuite/tests/ghci/T18262/T18262.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghci/T18262/all.T | 1 |
4 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/T18262/T18262.hs b/testsuite/tests/ghci/T18262/T18262.hs new file mode 100644 index 0000000000..1734de0179 --- /dev/null +++ b/testsuite/tests/ghci/T18262/T18262.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies, FlexibleInstances, DataKinds, UndecidableInstances #-} + +import GHC.TypeLits + +data C = A | B + +class Err (a :: C) + +instance (TypeError ('Text "uh-oh")) => Err 'A +instance Err 'B diff --git a/testsuite/tests/ghci/T18262/T18262.script b/testsuite/tests/ghci/T18262/T18262.script new file mode 100644 index 0000000000..9b70743fad --- /dev/null +++ b/testsuite/tests/ghci/T18262/T18262.script @@ -0,0 +1,6 @@ +:load T18262.hs +:set -XDataKinds +-- Should report no instances +:instances 'A +-- Should report an instance with no constraints +:instances 'B diff --git a/testsuite/tests/ghci/T18262/T18262.stdout b/testsuite/tests/ghci/T18262/T18262.stdout new file mode 100644 index 0000000000..76d7e8a596 --- /dev/null +++ b/testsuite/tests/ghci/T18262/T18262.stdout @@ -0,0 +1 @@ +instance [safe] Err 'B -- Defined at T18262.hs:10:10 diff --git a/testsuite/tests/ghci/T18262/all.T b/testsuite/tests/ghci/T18262/all.T new file mode 100644 index 0000000000..fe8e28fe6d --- /dev/null +++ b/testsuite/tests/ghci/T18262/all.T @@ -0,0 +1 @@ +test('T18262', [extra_files(['T18262.hs'])], ghci_script, ['T18262.script']) |