summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-01-02 17:25:58 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2018-01-03 11:26:20 +0000
commit9e5535ca667e060ce1431d42cdfc3a13ae080a88 (patch)
treea5c4d04e651397eeb059e4a539c57e82f8aab779 /testsuite
parent112266ce62e4fa831b21038be72f8b9ecdf6bfcf (diff)
downloadhaskell-9e5535ca667e060ce1431d42cdfc3a13ae080a88.tar.gz
Fix OptCoercion
In the presence of -fdefer-type-errors, OptCoercion can encounter a mal-formed coerercion with type T a ~ T a b and that was causing a subsequent Lint error. This caused Trac #14607. Easily fixed by turning an ASSERT into a guard.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/typecheck/should_fail/T14607.hs23
-rw-r--r--testsuite/tests/typecheck/should_fail/T14607.stderr21
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
3 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T14607.hs b/testsuite/tests/typecheck/should_fail/T14607.hs
new file mode 100644
index 0000000000..891d3ccc18
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T14607.hs
@@ -0,0 +1,23 @@
+{-# OPTIONS_GHC -fdefer-type-errors #-}
+ -- This line is crucial to the bug
+
+{-# Language GADTs #-}
+{-# Language InstanceSigs #-}
+{-# Language KindSignatures #-}
+{-# Language TypeFamilies #-}
+{-# Language DataKinds #-}
+{-# Language FlexibleInstances #-}
+
+module T14607 where
+
+import Data.Kind
+
+data LamCons :: Type -> Type -> () -> Type where
+ C :: LamCons a a '()
+
+class Mk a where
+ mk :: LamCons a a '()
+
+instance Mk a where
+ mk :: LamCons a '()
+ mk = mk
diff --git a/testsuite/tests/typecheck/should_fail/T14607.stderr b/testsuite/tests/typecheck/should_fail/T14607.stderr
new file mode 100644
index 0000000000..740f89a0d4
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T14607.stderr
@@ -0,0 +1,21 @@
+
+T14607.hs:22:9: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Expecting one more argument to ‘LamCons a '()’
+ Expected a type, but ‘LamCons a '()’ has kind ‘() -> *’
+ • In the type signature: mk :: LamCons a '()
+ In the instance declaration for ‘Mk a’
+
+T14607.hs:22:19: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Expected a type, but ‘ '()’ has kind ‘()’
+ • In the second argument of ‘LamCons’, namely ‘ '()’
+ In the type signature: mk :: LamCons a '()
+ In the instance declaration for ‘Mk a’
+
+T14607.hs:23:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘LamCons a '()’
+ with actual type ‘LamCons a0 a0 '()’
+ • In the expression: mk
+ In an equation for ‘mk’: mk = mk
+ In the instance declaration for ‘Mk a’
+ • Relevant bindings include
+ mk :: LamCons a '() (bound at T14607.hs:23:3)
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index b1a0e757ae..2d8137f694 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -463,3 +463,4 @@ test('T14350', normal, compile_fail, [''])
test('T14390', normal, compile_fail, [''])
test('MissingExportList03', normal, compile_fail, [''])
test('T14618', normal, compile_fail, [''])
+test('T14607', normal, compile, [''])