From 294b55dcff51fb9e419889d7262c7f053c919623 Mon Sep 17 00:00:00 2001
From: Eric Wolf <ericwolf42@gmail.com>
Date: Tue, 25 Jun 2019 20:34:55 +0200
Subject: [PATCH] Add test for #16575

just use the test to show the defective behaviour, so we can see
the difference, when it gets fixed
---
 testsuite/tests/ghci/scripts/T16575.hs     |  9 ++++++++
 testsuite/tests/ghci/scripts/T16575.script | 18 +++++++++++++++
 testsuite/tests/ghci/scripts/T16575.stdout | 26 ++++++++++++++++++++++
 testsuite/tests/ghci/scripts/all.T         |  1 +
 4 files changed, 54 insertions(+)
 create mode 100644 testsuite/tests/ghci/scripts/T16575.hs
 create mode 100644 testsuite/tests/ghci/scripts/T16575.script
 create mode 100644 testsuite/tests/ghci/scripts/T16575.stdout

diff --git a/testsuite/tests/ghci/scripts/T16575.hs b/testsuite/tests/ghci/scripts/T16575.hs
new file mode 100644
index 00000000000..08cd440d5c4
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T16575.hs
@@ -0,0 +1,9 @@
+module Ghost where
+
+data X = A | B
+    deriving (Show)
+
+instance Eq X where
+    A == A = True
+    B == B = True
+    _ == _ = False
diff --git a/testsuite/tests/ghci/scripts/T16575.script b/testsuite/tests/ghci/scripts/T16575.script
new file mode 100644
index 00000000000..0a251bddc04
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T16575.script
@@ -0,0 +1,18 @@
+:set +c
+:l T16575.hs
+:all-types
+
+-- data X = A | B
+--     deriving (Show)
+--               ^^^^
+:type-at T16575.hs 4 15 4 19
+-- wrongly outputs:
+--  :: [X] -> ShowS
+
+-- instance Eq X where
+--          ^^^^
+:type-at T16575.hs 6 10 6 14
+-- wrongly outputs:
+-- :: X -> X -> Bool
+
+-- also note how :all-types is inconsistent with :type-at
diff --git a/testsuite/tests/ghci/scripts/T16575.stdout b/testsuite/tests/ghci/scripts/T16575.stdout
new file mode 100644
index 00000000000..833fb02d80d
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T16575.stdout
@@ -0,0 +1,26 @@
+Collecting type info for 1 module(s) ... 
+T16575.hs:(4,15)-(4,18): GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS
+T16575.hs:(7,7)-(7,8): Ghost.X -> Ghost.X -> GHC.Types.Bool
+T16575.hs:(4,15)-(4,18): GHC.Show.Show Ghost.X
+T16575.hs:(4,15)-(4,18): ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X
+T16575.hs:(4,15)-(4,18): (Ghost.X -> GHC.Base.String) -> ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X
+T16575.hs:(4,15)-(4,18): (GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS) -> (Ghost.X -> GHC.Base.String) -> ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X
+T16575.hs:(4,15)-(4,18): GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS
+T16575.hs:(4,15)-(4,18): Ghost.X -> GHC.Base.String
+T16575.hs:(4,15)-(4,18): [Ghost.X] -> GHC.Show.ShowS
+T16575.hs:(6,10)-(6,13): GHC.Classes.Eq Ghost.X
+T16575.hs:(6,10)-(6,13): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> GHC.Classes.Eq Ghost.X
+T16575.hs:(6,10)-(6,13): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> GHC.Classes.Eq Ghost.X
+T16575.hs:(6,10)-(6,13): Ghost.X -> Ghost.X -> GHC.Types.Bool
+T16575.hs:(6,10)-(6,13): Ghost.X -> Ghost.X -> GHC.Types.Bool
+T16575.hs:(7,14)-(7,17): GHC.Types.Bool
+T16575.hs:(8,14)-(8,17): GHC.Types.Bool
+T16575.hs:(9,14)-(9,18): GHC.Types.Bool
+T16575.hs:(7,5)-(7,5): Ghost.X
+T16575.hs:(7,10)-(7,10): Ghost.X
+T16575.hs:(8,5)-(8,5): Ghost.X
+T16575.hs:(8,10)-(8,10): Ghost.X
+T16575.hs:(9,5)-(9,5): Ghost.X
+T16575.hs:(9,10)-(9,10): Ghost.X
+ :: [X] -> ShowS
+ :: X -> X -> Bool
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 6a16842ac77..e334b7e9628 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -300,3 +300,4 @@ test('T16527', normal, ghci_script, ['T16527.script'])
 test('T16563', extra_hc_opts("-clear-package-db -global-package-db"), ghci_script, ['T16563.script'])
 test('T16569', normal, ghci_script, ['T16569.script'])
 test('T16767', normal, ghci_script, ['T16767.script'])
+test('T16575', normal, ghci_script, ['T16575.script'])
-- 
GitLab