summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T18851.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_fail/T18851.hs')
-rw-r--r--testsuite/tests/typecheck/should_fail/T18851.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T18851.hs b/testsuite/tests/typecheck/should_fail/T18851.hs
new file mode 100644
index 0000000000..bba609a5ce
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T18851.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE FunctionalDependencies, FlexibleInstances, UndecidableInstances,
+ ScopedTypeVariables, TypeFamilies, TypeApplications,
+ FlexibleContexts, AllowAmbiguousTypes, ExtendedDefaultRules #-}
+
+module T18851 where
+
+default (Int)
+
+type family C_FD a
+class C_FD a ~ b => C a b
+
+type instance C_FD Int = Bool -- just for Show (C_FD Int)
+instance C Int b => C Int b
+
+class IsInt int
+instance int ~ Int => IsInt int
+
+data A
+instance Show A where
+ show _ = "A"
+data B
+instance Show B where
+ show _ = "B"
+
+f :: forall a b c int
+ . ( Show c, Num int
+ , C int a, C int b, C int c
+ -- , c ~ C_FD int -- add this to get rid of ambiguity error
+ )
+ => String
+f = show (undefined :: c)
+
+-- blows up at run time once type checks
+g :: String
+g = f @A @B