GHCi should not filter instances involving cTuples
authorAlec Theriault <alec.theriault@gmail.com>
Tue, 2 Oct 2018 12:48:00 +0000 (14:48 +0200)
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>
Tue, 2 Oct 2018 14:00:19 +0000 (16:00 +0200)
Summary: See the new T12005 test case for an example of this.

Test Plan: make TEST=T12005

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #12005

Differential Revision: https://phabricator.haskell.org/D5182

compiler/main/InteractiveEval.hs
testsuite/tests/ghci/scripts/T12005.script [new file with mode: 0644]
testsuite/tests/ghci/scripts/T12005.stdout [new file with mode: 0644]
testsuite/tests/ghci/scripts/all.T

index 452ccb3..3d9dc18 100644 (file)
@@ -76,6 +76,7 @@ import UniqSupply
 import MonadUtils
 import Module
 import PrelNames  ( toDynName, pretendNameIsInScope )
+import TysWiredIn ( isCTupleTyConName )
 import Panic
 import Maybes
 import ErrUtils
@@ -758,6 +759,7 @@ getInfo allInfo name
                        -- The one we looked for in the first place!
                | pretendNameIsInScope n = True
                | isBuiltInSyntax n      = True
+               | isCTupleTyConName n    = True
                | isExternalName n       = isJust (lookupGRE_Name rdr_env n)
                | otherwise              = True
 
diff --git a/testsuite/tests/ghci/scripts/T12005.script b/testsuite/tests/ghci/scripts/T12005.script
new file mode 100644 (file)
index 0000000..a86e7d5
--- /dev/null
@@ -0,0 +1,8 @@
+:set -XKindSignatures -XRank2Types -XConstraintKinds -XAllowAmbiguousTypes -XInstanceSigs
+
+import Data.Kind
+
+class Defer (p :: Constraint) where defer :: (p => r) -> r
+instance Defer () where defer :: r -> r; defer = id
+
+:i Defer
diff --git a/testsuite/tests/ghci/scripts/T12005.stdout b/testsuite/tests/ghci/scripts/T12005.stdout
new file mode 100644 (file)
index 0000000..34cde4a
--- /dev/null
@@ -0,0 +1,6 @@
+class Defer (p :: Constraint) where
+  defer :: (p => r) -> r
+  {-# MINIMAL defer #-}
+       -- Defined at <interactive>:5:1
+instance [safe] Defer (() :: Constraint)
+  -- Defined at <interactive>:6:10
index dcc4855..67c4b38 100755 (executable)
@@ -252,6 +252,7 @@ test('T12007', normal, ghci_script, ['T12007.script'])
 test('T11975', normal, ghci_script, ['T11975.script'])
 test('T10963', normal, ghci_script, ['T10963.script'])
 test('T11721', normal, ghci_script, ['T11721.script'])
+test('T12005', normal, ghci_script, ['T12005.script'])
 test('T12023', normal, run_command,
                ['$MAKE -s --no-print-directory T12023'])
 test('T12520', normal, ghci_script, ['T12520.script'])