summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-03-15 13:49:42 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-16 02:29:42 -0400
commitbb779b90bb093274ccf7a8e5b19f6661f4925bde (patch)
tree98c5621e4629bf730f6520fee83e1cf98bd70cf7
parent1575c4a5d9611a7299c33d3fd98f52ddeff84c80 (diff)
downloadhaskell-bb779b90bb093274ccf7a8e5b19f6661f4925bde.tar.gz
Add a regression test for #21130
This problem was due to a bug in cloneWanted, which was incorrectly creating a coercion hole to hold an evidence variable. This bug was introduced by 8bb52d91 and fixed in 81740ce8. Fixes #21130
-rw-r--r--testsuite/tests/typecheck/should_fail/T21130.hs10
-rw-r--r--testsuite/tests/typecheck/should_fail/T21130.stderr34
-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/T21130.hs b/testsuite/tests/typecheck/should_fail/T21130.hs
new file mode 100644
index 0000000000..abeafdb50a
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T21130.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
+module T21130 where
+
+type family Item l
+type instance Item [a] = a
+
+f :: Enum (Item l) => l
+f = f
+
+x = (_ f) :: Int
diff --git a/testsuite/tests/typecheck/should_fail/T21130.stderr b/testsuite/tests/typecheck/should_fail/T21130.stderr
new file mode 100644
index 0000000000..d1d018bc9f
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T21130.stderr
@@ -0,0 +1,34 @@
+
+T21130.hs:10:6:
+ Found hole: _ :: t0 -> Int
+ Where: ‘t0’ is an ambiguous type variable
+ In the expression: (_ f) :: Int
+ In an equation for ‘x’: x = (_ f) :: Int
+ Relevant bindings include x :: Int (bound at T21130.hs:10:1)
+ Valid hole fits include
+ head :: forall a. GHC.Stack.Types.HasCallStack => [a] -> a
+ with head @Int
+ (imported from ‘Prelude’ at T21130.hs:2:8-13
+ (and originally defined in ‘GHC.List’))
+ last :: forall a. GHC.Stack.Types.HasCallStack => [a] -> a
+ with last @Int
+ (imported from ‘Prelude’ at T21130.hs:2:8-13
+ (and originally defined in ‘GHC.List’))
+ read :: forall a. Read a => String -> a
+ with read @Int
+ (imported from ‘Prelude’ at T21130.hs:2:8-13
+ (and originally defined in ‘Text.Read’))
+
+ T21130.hs:10:8:
+ Ambiguous type variable ‘t0’ arising from a use of ‘f’
+ prevents the constraint ‘(Enum (Item t0))’ from being solved.
+ Probable fix: use a type annotation to specify what ‘t0’ should be.
+ Potentially matching instances:
+ instance Enum Ordering -- Defined in ‘GHC.Enum’
+ instance Enum Integer -- Defined in ‘GHC.Enum’
+ ...plus N others
+ ...plus N instances involving out-of-scope types
+ (use -fprint-potential-instances to see them all)
+ In the first argument of ‘_’, namely ‘f’
+ In the expression: (_ f) :: Int
+ In an equation for ‘x’: x = (_ f) :: Int
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 2febea800d..a8a4e4d3b5 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -650,3 +650,4 @@ test('T18398', normal, compile_fail, [''])
test('T18406', normal, compile_fail, [''])
test('AmbigFDs', normal, compile_fail, [''])
test('T20064', normal, compile_fail, [''])
+test('T21130', normal, compile_fail, [''])