summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-03-27 14:32:43 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2017-03-27 16:31:04 +0100
commitfeca929b8f7a7dfe96d06c27d405ce331cdcdb41 (patch)
treef9984489e23e2bba4f854249b3b6b5fd51e44864
parente0ad55f894a8d85dcc099c33c63cfe3d4515d464 (diff)
downloadhaskell-feca929b8f7a7dfe96d06c27d405ce331cdcdb41.tar.gz
Fix 'unsolved constraints' in GHCi
In initTc, if the computation fails with an exception, we should not complain about unsolved constraints. Fixes Trac #13466.
-rw-r--r--compiler/typecheck/TcRnMonad.hs11
-rw-r--r--testsuite/tests/ghci/scripts/T13466.script2
-rw-r--r--testsuite/tests/ghci/scripts/T13466.stderr5
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
4 files changed, 15 insertions, 4 deletions
diff --git a/compiler/typecheck/TcRnMonad.hs b/compiler/typecheck/TcRnMonad.hs
index 3404ce7c3d..2b73812de0 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 0000000000..0310facb13
--- /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 0000000000..ba3d5fda8f
--- /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 20bc5aea56..00d8d819bc 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'])