[commit: ghc] master: Driver: `ghci -e` should behave like `ghc -e` (#9360) (7bbb61b)
git at git.haskell.org
git at git.haskell.org
Mon Oct 19 15:56:32 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/7bbb61bc969c27a38b26a605d5ac70ac98c328d9/ghc
>---------------------------------------------------------------
commit 7bbb61bc969c27a38b26a605d5ac70ac98c328d9
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Sat Oct 17 12:15:32 2015 +0200
Driver: `ghci -e` should behave like `ghc -e` (#9360)
Patch by lukyanov.
Reviewed by: bgamari
Differential Revision: https://phabricator.haskell.org/D1337
>---------------------------------------------------------------
7bbb61bc969c27a38b26a605d5ac70ac98c328d9
docs/users_guide/7.12.1-notes.rst | 6 ++++--
ghc/Main.hs | 13 +++++++++++++
testsuite/tests/driver/all.T | 3 +++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/docs/users_guide/7.12.1-notes.rst b/docs/users_guide/7.12.1-notes.rst
index 05ab2e2..e05366c 100644
--- a/docs/users_guide/7.12.1-notes.rst
+++ b/docs/users_guide/7.12.1-notes.rst
@@ -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
~~~~~~~~~~~~~~~~
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 4ef44f2..fc6ab88 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -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), [])
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index 17e0784..08fdc1f 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -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'])
More information about the ghc-commits
mailing list