diff options
author | Zejun Wu <watashi@fb.com> | 2018-12-17 23:35:44 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-12-17 23:36:53 -0500 |
commit | a0fb20bae31ed7a50d1a6e4e15c42ba25d836bfc (patch) | |
tree | 8a2bee666e0e2c443afed18808802f1429b833b1 /ghc | |
parent | ed69f8bd1fd4b84b62bb4f10eef7f76e537be07b (diff) | |
download | haskell-a0fb20bae31ed7a50d1a6e4e15c42ba25d836bfc.tar.gz |
Fix ghci crash when starting with -fno-implicit-import-qualified
`ghci -fno-implicit-import-qualified` didn't start with error message:
```
GHCi, version 8.6.2: http://www.haskell.org/ghc/ :? for help
<interactive>:1:6: error:
Not in scope: ‘System.IO.hSetBuffering’
No module named ‘System.IO’ is imported.
...
```
This change fixes it and update test T2452 to cover this.
Test Plan:
TEST=T2452 make accept
harbormaster build runs
Reviewers: simonmar, bgamari, RyanGlScott
Reviewed By: simonmar
Subscribers: rwbarton, carter
Differential Revision: https://phabricator.haskell.org/D5452
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI/Monad.hs | 25 |
1 files changed, 13 insertions, 12 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 + } |