summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-01-07 11:39:19 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-01-11 19:43:57 -0500
commit833216a31c866d86ff95cfbf95591fb56463371c (patch)
treec1207669ca0c024b3f517a197a1313d81ee8437a
parent23d215fcb62c8bfe8d56396a0c9718a72ac0037b (diff)
downloadhaskell-833216a31c866d86ff95cfbf95591fb56463371c.tar.gz
Use interactive flags when printing expressions in GHCi
The documentation states that the interactive flags should be use for any interactive expressions. The interactive flags are used when typechecking these expressions but not when printing. The session flags (modified by :set) are only used when loading a module. Fixes #20909
-rw-r--r--ghc/GHCi/UI/Monad.hs8
-rw-r--r--testsuite/tests/ghci/scripts/T20909.script3
-rw-r--r--testsuite/tests/ghci/scripts/T20909.stdout1
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
4 files changed, 9 insertions, 4 deletions
diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs
index 157b9e8950..3aead3e91e 100644
--- a/ghc/GHCi/UI/Monad.hs
+++ b/ghc/GHCi/UI/Monad.hs
@@ -344,12 +344,12 @@ unsetOption opt
printForUserNeverQualify :: GhcMonad m => SDoc -> m ()
printForUserNeverQualify doc = do
- dflags <- getDynFlags
+ dflags <- GHC.getInteractiveDynFlags
liftIO $ Ppr.printForUser dflags stdout neverQualify AllTheWay doc
printForUserModInfo :: GhcMonad m => GHC.ModuleInfo -> SDoc -> m ()
printForUserModInfo info doc = do
- dflags <- getDynFlags
+ dflags <- GHC.getInteractiveDynFlags
mUnqual <- GHC.mkPrintUnqualifiedForModule info
unqual <- maybe GHC.getPrintUnqual return mUnqual
liftIO $ Ppr.printForUser dflags stdout unqual AllTheWay doc
@@ -357,13 +357,13 @@ printForUserModInfo info doc = do
printForUser :: GhcMonad m => SDoc -> m ()
printForUser doc = do
unqual <- GHC.getPrintUnqual
- dflags <- getDynFlags
+ dflags <- GHC.getInteractiveDynFlags
liftIO $ Ppr.printForUser dflags stdout unqual AllTheWay doc
printForUserPartWay :: GhcMonad m => SDoc -> m ()
printForUserPartWay doc = do
unqual <- GHC.getPrintUnqual
- dflags <- getDynFlags
+ dflags <- GHC.getInteractiveDynFlags
liftIO $ Ppr.printForUser dflags stdout unqual DefaultDepth doc
-- | Run a single Haskell expression
diff --git a/testsuite/tests/ghci/scripts/T20909.script b/testsuite/tests/ghci/scripts/T20909.script
new file mode 100644
index 0000000000..8cd302b33e
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T20909.script
@@ -0,0 +1,3 @@
+:seti -fprint-explicit-foralls
+:type id
+
diff --git a/testsuite/tests/ghci/scripts/T20909.stdout b/testsuite/tests/ghci/scripts/T20909.stdout
new file mode 100644
index 0000000000..f2bad173c8
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T20909.stdout
@@ -0,0 +1 @@
+id :: forall a. a -> a
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 5cdbd8a21c..5e9aea056d 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -353,3 +353,4 @@ test('T20473a', normal, ghci_script, ['T20473a.script'])
test('T20473b', normal, ghci_script, ['T20473b.script'])
test('T20587', [extra_files(['../shell.hs'])], ghci_script,
['T20587.script'])
+test('T20909', normal, ghci_script, ['T20909.script'])