[commit: ghc] master: ghci: fix trac issue #11481 (1f6d142)

git at git.haskell.org git at git.haskell.org
Wed Jan 27 10:31:00 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/1f6d1422f9fe875e1d150b423c4864b42d96b8db/ghc

>---------------------------------------------------------------

commit 1f6d1422f9fe875e1d150b423c4864b42d96b8db
Author: Benjamin Bykowski <alpha-theta at web.de>
Date:   Wed Jan 27 11:05:13 2016 +0100

    ghci: fix trac issue #11481
    
    Test Plan: validate
    
    Reviewers: thomie, austin, bgamari
    
    Reviewed By: bgamari
    
    Differential Revision: https://phabricator.haskell.org/D1833
    
    GHC Trac Issues: #11481


>---------------------------------------------------------------

1f6d1422f9fe875e1d150b423c4864b42d96b8db
 compiler/main/DynFlags.hs                 |  2 +-
 ghc/GHCi/UI.hs                            | 13 +++----
 testsuite/tests/ghci/scripts/Defer03.hs   |  5 ++-
 testsuite/tests/ghci/scripts/T8353.stderr | 60 +++++++++++++++++++++++--------
 4 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 0e9d420..83de48c 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -28,7 +28,7 @@ module DynFlags (
         ProfAuto(..),
         glasgowExtsFlags,
         dopt, dopt_set, dopt_unset,
-        gopt, gopt_set, gopt_unset,
+        gopt, gopt_set, gopt_unset, setGeneralFlag', unSetGeneralFlag',
         wopt, wopt_set, wopt_unset,
         xopt, xopt_set, xopt_unset,
         lang_set,
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index fc03b5f..2528503 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -1460,17 +1460,14 @@ checkModule m = do
 -- :load, :add, :reload
 
 -- | Sets '-fdefer-type-errors' if 'defer' is true, executes 'load' and unsets
--- '-fdefer-type-errors' again if it has not been set before
+-- '-fdefer-type-errors' again if it has not been set before.
 deferredLoad :: Bool -> InputT GHCi SuccessFlag -> InputT GHCi ()
 deferredLoad defer load = do
-  flags <- getDynFlags
-  deferredBefore <- return (gopt Opt_DeferTypeErrors flags)
-  when (defer) $ Monad.void $
-    GHC.setProgramDynFlags $ gopt_set flags Opt_DeferTypeErrors
+  originalFlags <- getDynFlags
+  when defer $ Monad.void $
+    GHC.setProgramDynFlags $ setGeneralFlag' Opt_DeferTypeErrors originalFlags
   Monad.void $ load
-  flags <- getDynFlags
-  when (not deferredBefore) $ Monad.void $
-    GHC.setProgramDynFlags $ gopt_unset flags Opt_DeferTypeErrors
+  Monad.void $ GHC.setProgramDynFlags $ originalFlags
 
 loadModule :: [(FilePath, Maybe Phase)] -> InputT GHCi SuccessFlag
 loadModule fs = timeIt (const Nothing) (loadModule' fs)
diff --git a/testsuite/tests/ghci/scripts/Defer03.hs b/testsuite/tests/ghci/scripts/Defer03.hs
index b91a7ac..b0f65fb 100755
--- a/testsuite/tests/ghci/scripts/Defer03.hs
+++ b/testsuite/tests/ghci/scripts/Defer03.hs
@@ -3,5 +3,8 @@ module Main where
 a :: Int
 a = 'p'
 
+f :: Int
+f = _
+
 main :: IO ()
-main = print "No errors!"
+main = print f
diff --git a/testsuite/tests/ghci/scripts/T8353.stderr b/testsuite/tests/ghci/scripts/T8353.stderr
index 7303142..8914820 100644
--- a/testsuite/tests/ghci/scripts/T8353.stderr
+++ b/testsuite/tests/ghci/scripts/T8353.stderr
@@ -1,25 +1,55 @@
 
 Defer03.hs:4:5: warning:
-    Couldn't match expected type ‘Int’ with actual type ‘Char’
-    In the expression: 'p'
-    In an equation for ‘a’: a = 'p'
+    • Couldn't match expected type ‘Int’ with actual type ‘Char’
+    • In the expression: 'p'
+      In an equation for ‘a’: a = 'p'
+
+Defer03.hs:7:5: warning:
+    • Found hole: _ :: Int
+    • In the expression: _
+      In an equation for ‘f’: f = _
+    • Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
 
 Defer03.hs:4:5: error:
-    Couldn't match expected type ‘Int’ with actual type ‘Char’
-    In the expression: 'p'
-    In an equation for ‘a’: a = 'p'
+    • Couldn't match expected type ‘Int’ with actual type ‘Char’
+    • In the expression: 'p'
+      In an equation for ‘a’: a = 'p'
+
+Defer03.hs:7:5: error:
+    • Found hole: _ :: Int
+    • In the expression: _
+      In an equation for ‘f’: f = _
+    • Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
 
 Defer03.hs:4:5: warning:
-    Couldn't match expected type ‘Int’ with actual type ‘Char’
-    In the expression: 'p'
-    In an equation for ‘a’: a = 'p'
+    • Couldn't match expected type ‘Int’ with actual type ‘Char’
+    • In the expression: 'p'
+      In an equation for ‘a’: a = 'p'
+
+Defer03.hs:7:5: warning:
+    • Found hole: _ :: Int
+    • In the expression: _
+      In an equation for ‘f’: f = _
+    • Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
 
 Defer03.hs:4:5: error:
-    Couldn't match expected type ‘Int’ with actual type ‘Char’
-    In the expression: 'p'
-    In an equation for ‘a’: a = 'p'
+    • Couldn't match expected type ‘Int’ with actual type ‘Char’
+    • In the expression: 'p'
+      In an equation for ‘a’: a = 'p'
+
+Defer03.hs:7:5: error:
+    • Found hole: _ :: Int
+    • In the expression: _
+      In an equation for ‘f’: f = _
+    • Relevant bindings include f :: Int (bound at Defer03.hs:7:1)
 
 Defer03.hs:4:5: warning:
-    Couldn't match expected type ‘Int’ with actual type ‘Char’
-    In the expression: 'p'
-    In an equation for ‘a’: a = 'p'
+    • Couldn't match expected type ‘Int’ with actual type ‘Char’
+    • In the expression: 'p'
+      In an equation for ‘a’: a = 'p'
+
+Defer03.hs:7:5: warning:
+    • Found hole: _ :: Int
+    • In the expression: _
+      In an equation for ‘f’: f = _
+    • Relevant bindings include f :: Int (bound at Defer03.hs:7:1)



More information about the ghc-commits mailing list