diff options
-rw-r--r-- | ghc/GHCi/UI/Monad.hs | 25 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T2452.script | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T2452.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T2452.stdout | 2 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 3 |
5 files changed, 24 insertions, 13 deletions
diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs index a3c21d8c01..969111b214 100644 --- a/ghc/GHCi/UI/Monad.hs +++ b/ghc/GHCi/UI/Monad.hs @@ -458,15 +458,16 @@ mkEvalWrapper progname args = "(System.Environment.withArgs " ++ show args ++ " m)" compileGHCiExpr :: GhcMonad m => String -> m ForeignHValue -compileGHCiExpr expr = do - hsc_env <- getSession - let dflags = hsc_dflags hsc_env - -- RebindableSyntax can wreak havoc with GHCi in several ways - -- (see #13385 and #14342 for examples), so we take care to disable it - -- for the duration of running expressions that are internal to GHCi. - no_rb_hsc_env = - hsc_env { hsc_dflags = xopt_unset dflags LangExt.RebindableSyntax } - setSession no_rb_hsc_env - res <- GHC.compileExprRemote expr - setSession hsc_env - pure res +compileGHCiExpr expr = + withTempSession mkTempSession $ GHC.compileExprRemote expr + where + mkTempSession hsc_env = hsc_env + { hsc_dflags = (hsc_dflags hsc_env) + -- RebindableSyntax can wreak havoc with GHCi in several ways + -- (see #13385 and #14342 for examples), so we take care to disable it + -- for the duration of running expressions that are internal to GHCi. + `xopt_unset` LangExt.RebindableSyntax + -- We heavily depend on -fimplicit-import-qualified to compile expr + -- with fully qualified names without imports. + `gopt_set` Opt_ImplicitImportQualified + } diff --git a/testsuite/tests/ghci/scripts/T2452.script b/testsuite/tests/ghci/scripts/T2452.script index 28d2bdc580..ef60f82e7a 100644 --- a/testsuite/tests/ghci/scripts/T2452.script +++ b/testsuite/tests/ghci/scripts/T2452.script @@ -1,2 +1,5 @@ +:t System.IO.hPutStrLn +:set -fimplicit-import-qualified +:t System.IO.hPutStrLn :set -fno-implicit-import-qualified :t System.IO.hPutStrLn diff --git a/testsuite/tests/ghci/scripts/T2452.stderr b/testsuite/tests/ghci/scripts/T2452.stderr index 663742f67c..99b0acbd21 100644 --- a/testsuite/tests/ghci/scripts/T2452.stderr +++ b/testsuite/tests/ghci/scripts/T2452.stderr @@ -2,3 +2,7 @@ <interactive>:1:1: error: Not in scope: ‘System.IO.hPutStrLn’ No module named ‘System.IO’ is imported. + +<interactive>:1:1: error: + Not in scope: ‘System.IO.hPutStrLn’ + No module named ‘System.IO’ is imported. diff --git a/testsuite/tests/ghci/scripts/T2452.stdout b/testsuite/tests/ghci/scripts/T2452.stdout new file mode 100644 index 0000000000..b2dc3f68b2 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T2452.stdout @@ -0,0 +1,2 @@ +System.IO.hPutStrLn + :: GHC.IO.Handle.Types.Handle -> String -> IO () diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index c58f5872cf..13753cd3ec 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -108,7 +108,8 @@ test('ghci062', [extra_files(['ghci062/', 'ghci062/Test.hs']), ghci_script, ['ghci062.script']) test('ghci063', normal, ghci_script, ['ghci063.script']) -test('T2452', normal, ghci_script, ['T2452.script']) +test('T2452', [extra_hc_opts("-fno-implicit-import-qualified")], + ghci_script, ['T2452.script']) test('T2766', normal, ghci_script, ['T2766.script']) test('T1914', [], ghci_script, ['T1914.script']) |