summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Denis <xldenis@gmail.com>2019-07-08 14:58:46 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-07-23 11:43:59 -0400
commit4c7a84627556cda9491300ba61f3060e357bc3ac (patch)
treed7b01317e98fdb232a6bf9af8cd99c9b2f5f4450
parent4854a3490518760405f04826df1768b5a7b96da2 (diff)
downloadhaskell-4c7a84627556cda9491300ba61f3060e357bc3ac.tar.gz
Make sure to load interfaces when running :instances
-rw-r--r--compiler/main/InteractiveEval.hs4
-rw-r--r--testsuite/tests/ghci/T16793/T16793.script1
-rw-r--r--testsuite/tests/ghci/T16793/T16793.stdout9
-rw-r--r--testsuite/tests/ghci/T16793/all.T1
-rw-r--r--testsuite/tests/ghci/scripts/ghci064.stdout18
5 files changed, 32 insertions, 1 deletions
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index ee43aaf675..88c8ecc7df 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -104,7 +104,7 @@ import GHC.Exts
import Data.Array
import Exception
-import TcRnDriver ( runTcInteractive, tcRnType )
+import TcRnDriver ( runTcInteractive, tcRnType, loadUnqualIfaces )
import TcHsSyn ( ZonkFlexi (SkolemiseFlexi) )
import TcEnv (tcGetInstEnvs)
@@ -1048,6 +1048,8 @@ getInstancesForType :: GhcMonad m => Type -> m [ClsInst]
getInstancesForType ty = withSession $ \hsc_env -> do
liftIO $ runInteractiveHsc hsc_env $ do
ioMsgMaybe $ runTcInteractive hsc_env $ do
+ -- Bring class and instances from unqualified modules into scope, this fixes #16793.
+ loadUnqualIfaces hsc_env (hsc_IC hsc_env)
matches <- findMatchingInstances ty
fmap catMaybes . forM matches $ uncurry checkForExistence
diff --git a/testsuite/tests/ghci/T16793/T16793.script b/testsuite/tests/ghci/T16793/T16793.script
new file mode 100644
index 0000000000..9344a014ef
--- /dev/null
+++ b/testsuite/tests/ghci/T16793/T16793.script
@@ -0,0 +1 @@
+:instances Int
diff --git a/testsuite/tests/ghci/T16793/T16793.stdout b/testsuite/tests/ghci/T16793/T16793.stdout
new file mode 100644
index 0000000000..e20747293e
--- /dev/null
+++ b/testsuite/tests/ghci/T16793/T16793.stdout
@@ -0,0 +1,9 @@
+instance Eq Int -- Defined in ‘GHC.Classes’
+instance Ord Int -- Defined in ‘GHC.Classes’
+instance Enum Int -- Defined in ‘GHC.Enum’
+instance Num Int -- Defined in ‘GHC.Num’
+instance Real Int -- Defined in ‘GHC.Real’
+instance Show Int -- Defined in ‘GHC.Show’
+instance Read Int -- Defined in ‘GHC.Read’
+instance Bounded Int -- Defined in ‘GHC.Enum’
+instance Integral Int -- Defined in ‘GHC.Real’
diff --git a/testsuite/tests/ghci/T16793/all.T b/testsuite/tests/ghci/T16793/all.T
new file mode 100644
index 0000000000..4efc926719
--- /dev/null
+++ b/testsuite/tests/ghci/T16793/all.T
@@ -0,0 +1 @@
+test('T16793', normal, ghci_script, ['T16793.script'])
diff --git a/testsuite/tests/ghci/scripts/ghci064.stdout b/testsuite/tests/ghci/scripts/ghci064.stdout
index 2b841138ce..91298153fc 100644
--- a/testsuite/tests/ghci/scripts/ghci064.stdout
+++ b/testsuite/tests/ghci/scripts/ghci064.stdout
@@ -3,27 +3,45 @@ instance Applicative Maybe -- Defined in ‘GHC.Base’
instance Functor Maybe -- Defined in ‘GHC.Base’
instance Monad Maybe -- Defined in ‘GHC.Base’
instance GHC.Base.MonadPlus Maybe -- Defined in ‘GHC.Base’
+instance MonadFail Maybe -- Defined in ‘Control.Monad.Fail’
+instance Foldable Maybe -- Defined in ‘Data.Foldable’
+instance Traversable Maybe -- Defined in ‘Data.Traversable’
instance Eq _ => Eq (Maybe _) -- Defined in ‘GHC.Maybe’
instance Semigroup _ => Monoid (Maybe _) -- Defined in ‘GHC.Base’
instance Ord _ => Ord (Maybe _) -- Defined in ‘GHC.Maybe’
instance Semigroup _ => Semigroup (Maybe _)
-- Defined in ‘GHC.Base’
instance Show _ => Show (Maybe _) -- Defined in ‘GHC.Show’
+instance Read _ => Read (Maybe _) -- Defined in ‘GHC.Read’
+instance GHC.Generics.Generic (Maybe _)
+ -- Defined in ‘GHC.Generics’
+instance GHC.Generics.SingKind _ => GHC.Generics.SingKind (Maybe _)
+ -- Defined in ‘GHC.Generics’
instance Eq _ => Eq [_] -- Defined in ‘GHC.Classes’
instance Monoid [_] -- Defined in ‘GHC.Base’
instance Ord _ => Ord [_] -- Defined in ‘GHC.Classes’
instance Semigroup [_] -- Defined in ‘GHC.Base’
instance Show _ => Show [_] -- Defined in ‘GHC.Show’
+instance Read _ => Read [_] -- Defined in ‘GHC.Read’
+instance GHC.Generics.Generic [_] -- Defined in ‘GHC.Generics’
instance [safe] MyShow _ => MyShow [_]
-- Defined at ghci064.hs:7:10
instance Monoid [T] -- Defined in ‘GHC.Base’
instance Semigroup [T] -- Defined in ‘GHC.Base’
+instance GHC.Generics.Generic [T] -- Defined in ‘GHC.Generics’
instance [safe] MyShow [T] -- Defined at ghci064.hs:7:10
instance [safe] MyShow [T] -- Defined at ghci064.hs:15:10
instance Eq Bool -- Defined in ‘GHC.Classes’
instance Ord Bool -- Defined in ‘GHC.Classes’
instance Enum Bool -- Defined in ‘GHC.Enum’
instance Show Bool -- Defined in ‘GHC.Show’
+instance Read Bool -- Defined in ‘GHC.Read’
instance Bounded Bool -- Defined in ‘GHC.Enum’
+instance GHC.Generics.Generic Bool -- Defined in ‘GHC.Generics’
+instance GHC.Arr.Ix Bool -- Defined in ‘GHC.Arr’
+instance GHC.Generics.SingKind Bool -- Defined in ‘GHC.Generics’
+instance Data.Bits.Bits Bool -- Defined in ‘Data.Bits’
+instance Data.Bits.FiniteBits Bool -- Defined in ‘Data.Bits’
instance Functor ((,) Int) -- Defined in ‘GHC.Base’
instance Foldable ((,) Int) -- Defined in ‘Data.Foldable’
+instance Traversable ((,) Int) -- Defined in ‘Data.Traversable’