Commit 7bbb61bc authored by thomie's avatar thomie

Driver: `ghci -e` should behave like `ghc -e` (#9360)

Patch by lukyanov.

Reviewed by: bgamari

Differential Revision: https://phabricator.haskell.org/D1337
parent 40235c38
......@@ -108,14 +108,16 @@ GHCi
- ``Main`` with an explicit module header but without ``main`` is now
an error (#7765).
The ``:back`` and ``:forward`` commands now take an optional count
- The ``:back`` and ``:forward`` commands now take an optional count
allowing the user to move forward or backward in history several
steps at a time.
Added commands ``:load!`` and ``:reload!``, effectively setting
- Added commands ``:load!`` and ``:reload!``, effectively setting
"-fdefer-type-errors" before loading a module and unsetting it after
loading if it has not been set before (#8353).
- ``ghci -e`` now behaves like ``ghc -e`` (#9360).
Template Haskell
~~~~~~~~~~~~~~~~
......
......@@ -492,6 +492,10 @@ isDoMakeMode :: Mode -> Bool
isDoMakeMode (Right (Right DoMake)) = True
isDoMakeMode _ = False
isDoEvalMode :: Mode -> Bool
isDoEvalMode (Right (Right (DoEval _))) = True
isDoEvalMode _ = False
#ifdef GHCI
isInteractiveMode :: PostLoadMode -> Bool
isInteractiveMode DoInteractive = True
......@@ -629,6 +633,15 @@ setMode newMode newFlag = liftEwM $ do
| isShowGhcUsageMode newMode &&
isDoInteractiveMode oldMode ->
((showGhciUsageMode, newFlag), [])
-- If we have both -e and --interactive then -e always wins
_ | isDoEvalMode oldMode &&
isDoInteractiveMode newMode ->
((oldMode, oldFlag), [])
| isDoEvalMode newMode &&
isDoInteractiveMode oldMode ->
((newMode, newFlag), [])
-- Otherwise, --help/--version/--numeric-version always win
| isDominantFlag oldMode -> ((oldMode, oldFlag), [])
| isDominantFlag newMode -> ((newMode, newFlag), [])
......
......@@ -453,3 +453,6 @@ test('T365',
unless(opsys('mingw32'), skip)],
compile_fail,
[''])
test('T9360a', normal, run_command, ['{compiler} --interactive -e ""'])
test('T9360b', normal, run_command, ['{compiler} -e "" --interactive'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment