[commit: ghc] master: Fix 'unsolved constraints' in GHCi (feca929)

git at git.haskell.org git at git.haskell.org
Mon Mar 27 15:31:59 UTC 2017


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

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

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

commit feca929b8f7a7dfe96d06c27d405ce331cdcdb41
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Mar 27 14:32:43 2017 +0100

    Fix 'unsolved constraints' in GHCi
    
    In initTc, if the computation fails with an exception, we
    should not complain about unsolved constraints.
    
    Fixes Trac #13466.


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

feca929b8f7a7dfe96d06c27d405ce331cdcdb41
 compiler/typecheck/TcRnMonad.hs            | 11 +++++++----
 testsuite/tests/ghci/scripts/T13466.script |  2 ++
 testsuite/tests/ghci/scripts/T13466.stderr |  5 +++++
 testsuite/tests/ghci/scripts/all.T         |  1 +
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/compiler/typecheck/TcRnMonad.hs b/compiler/typecheck/TcRnMonad.hs
index 3404ce7..2b73812 100644
--- a/compiler/typecheck/TcRnMonad.hs
+++ b/compiler/typecheck/TcRnMonad.hs
@@ -336,11 +336,14 @@ initTcWithGbl hsc_env gbl_env loc do_this
                           Right res -> return (Just res)
                           Left _    -> return Nothing }
 
-        -- Check for unsolved constraints
+      -- Check for unsolved constraints
+      -- If we succeed (maybe_res = Just r), there should be
+      -- no unsolved constraints.  But if we exit via an
+      -- exception (maybe_res = Nothing), we may have skipped
+      -- solving, so don't panic then (Trac #13466)
       ; lie <- readIORef (tcl_lie lcl_env)
-      ; if isEmptyWC lie
-           then return ()
-           else pprPanic "initTc: unsolved constraints" (ppr lie)
+      ; when (isJust maybe_res && not (isEmptyWC lie)) $
+        pprPanic "initTc: unsolved constraints" (ppr lie)
 
         -- Collect any error messages
       ; msgs <- readIORef (tcl_errs lcl_env)
diff --git a/testsuite/tests/ghci/scripts/T13466.script b/testsuite/tests/ghci/scripts/T13466.script
new file mode 100644
index 0000000..0310fac
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T13466.script
@@ -0,0 +1,2 @@
+:set -XTypeApplications
+:t out_of_scope @[]
diff --git a/testsuite/tests/ghci/scripts/T13466.stderr b/testsuite/tests/ghci/scripts/T13466.stderr
new file mode 100644
index 0000000..ba3d5fd
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T13466.stderr
@@ -0,0 +1,5 @@
+
+<interactive>:1:1: error:
+    • Cannot apply expression of type ‘t1’
+      to a visible type argument ‘[]’
+    • In the expression: out_of_scope @[]
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 20bc5ae..00d8d81 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -250,3 +250,4 @@ test('T12550', normal, ghci_script, ['T12550.script'])
 test('StaticPtr', normal, ghci_script, ['StaticPtr.script'])
 test('T13202', normal, ghci_script, ['T13202.script'])
 test('T13202a', normal, ghci_script, ['T13202a.script'])
+test('T13466', normal, ghci_script, ['T13466.script'])



More information about the ghc-commits mailing list