[commit: ghc] master: GHCi should not defer typed holes (71c0cc1)

git at git.haskell.org git at git.haskell.org
Sun Nov 29 12:22:01 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/71c0cc1531c3e548e47f435432ed31cb79512607/ghc

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

commit 71c0cc1531c3e548e47f435432ed31cb79512607
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Fri Nov 27 16:19:24 2015 +0100

    GHCi should not defer typed holes
    
    In the function `tcUserStmt` in compiler/typecheck/TcRnDriver.hs, before
    going over the different ways ('plans') to lift an expression typed at
    the prompt into the GHCi monad, `Opt_DeferTypeErrors` is disabled. Here is
    the accompanying comment:
    
    ```
    -- Ensure that type errors don't get deferred when type checking the
    -- naked expression. Deferring type errors here is unhelpful because the
    -- expression gets evaluated right away anyway. It also would potentially
    -- emit redundant type-error warnings, one from each plan.
    ; plan <- unsetGOptM Opt_DeferTypeErrors $
    ```
    
    Since `Opt_DeferTypeErrors` implies `Opt_DeferTypedHoles`,
    `Opt_DeferTypedHoles` should be disabled here as well. This improves
    the error message for T10248 (it doesn't mention ghciStepIO anymore).
    This is a partial fix for #10249, and a complete fix for #11130.
    
    Depends on D1526
    
    Reviewers: simonpj, austin, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: simonpj
    
    Differential Revision: https://phabricator.haskell.org/D1527
    
    GHC Trac Issues: #10249, #11130


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

71c0cc1531c3e548e47f435432ed31cb79512607
 compiler/typecheck/TcRnDriver.hs           |  3 ++-
 testsuite/tests/ghci/scripts/T10248.stderr | 26 ++++++++++++--------------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index fb27c26..3c68dcf 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -1641,7 +1641,8 @@ tcUserStmt (L loc (BodyStmt expr _ _ _))
         -- naked expression. Deferring type errors here is unhelpful because the
         -- expression gets evaluated right away anyway. It also would potentially
         -- emit two redundant type-error warnings, one from each plan.
-        ; plan <- unsetGOptM Opt_DeferTypeErrors $ runPlans [
+        ; plan <- unsetGOptM Opt_DeferTypeErrors $
+                  unsetGOptM Opt_DeferTypedHoles $ runPlans [
                     -- Plan A
                     do { stuff@([it_id], _) <- tcGhciStmts [bind_stmt, print_it]
                        ; it_ty <- zonkTcType (idType it_id)
diff --git a/testsuite/tests/ghci/scripts/T10248.stderr b/testsuite/tests/ghci/scripts/T10248.stderr
index 59b0b29..86b8c8d 100644
--- a/testsuite/tests/ghci/scripts/T10248.stderr
+++ b/testsuite/tests/ghci/scripts/T10248.stderr
@@ -1,16 +1,14 @@
 
-<interactive>:2:10: warning:
-    Found hole: _ :: IO ()
+<interactive>:2:10: error:
+    Found hole: _ :: f a
+    Where: ‘f’ is a rigid type variable bound by
+               the inferred type of it :: Functor f => f (Maybe a)
+               at <interactive>:2:1
+           ‘a’ is a rigid type variable bound by
+               the inferred type of it :: Functor f => f (Maybe a)
+               at <interactive>:2:1
     In the second argument of ‘(<$>)’, namely ‘_’
-    In the first argument of ‘ghciStepIO :: IO a -> IO a’, namely
-      ‘Just <$> _’
-    In a stmt of an interactive GHCi command:
-      it <- ghciStepIO :: IO a -> IO a (Just <$> _)
-*** Exception: <interactive>:2:10: error:
-    Found hole: _ :: IO ()
-    In the second argument of ‘(<$>)’, namely ‘_’
-    In the first argument of ‘ghciStepIO :: IO a -> IO a’, namely
-      ‘Just <$> _’
-    In a stmt of an interactive GHCi command:
-      it <- ghciStepIO :: IO a -> IO a (Just <$> _)
-(deferred type error)
+    In the expression: Just <$> _
+    In an equation for ‘it’: it = Just <$> _
+    Relevant bindings include
+      it :: f (Maybe a) (bound at <interactive>:2:1)



More information about the ghc-commits mailing list