summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2019-11-08 09:22:02 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-11-09 18:04:14 -0500
commit1f98e47df40ae84423283bf2e06ffe7a0b4a9381 (patch)
tree561b4fa063ef9dfda47c8f716db08ffddb6d23f6
parent011f3121955cf08353e384e9b84ed387860ade45 (diff)
downloadhaskell-1f98e47df40ae84423283bf2e06ffe7a0b4a9381.tar.gz
Use the right type in :force
A missing prime meant that we were considering the wrong type in the GHCi debugger, when doing :force on multiple arguments (issue #17431). The fix is trivial.
-rw-r--r--compiler/ghci/Debugger.hs8
-rw-r--r--testsuite/tests/ghci/scripts/T17431.hs10
-rw-r--r--testsuite/tests/ghci/scripts/T17431.script4
-rw-r--r--testsuite/tests/ghci/scripts/T17431.stdout11
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
5 files changed, 31 insertions, 3 deletions
diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs
index d803c0b729..a9bf9a87e9 100644
--- a/compiler/ghci/Debugger.hs
+++ b/compiler/ghci/Debugger.hs
@@ -74,7 +74,8 @@ pprintClosureCommand bindThings force str = do
-- Do the obtainTerm--bindSuspensions-computeSubstitution dance
go :: GhcMonad m => TCvSubst -> Id -> m (TCvSubst, Term)
go subst id = do
- let id' = id `setIdType` substTy subst (idType id)
+ let id_ty' = substTy subst (idType id)
+ id' = id `setIdType` id_ty'
term_ <- GHC.obtainTermFromId maxBound force id'
term <- tidyTermTyVars term_
term' <- if bindThings
@@ -85,13 +86,14 @@ pprintClosureCommand bindThings force str = do
-- mapping the old tyvars to the reconstructed types.
let reconstructed_type = termType term
hsc_env <- getSession
- case (improveRTTIType hsc_env (idType id) (reconstructed_type)) of
+ case (improveRTTIType hsc_env id_ty' reconstructed_type) of
Nothing -> return (subst, term')
Just subst' -> do { dflags <- GHC.getSessionDynFlags
; liftIO $
dumpIfSet_dyn dflags Opt_D_dump_rtti "RTTI"
(fsep $ [text "RTTI Improvement for", ppr id,
- text "is the substitution:" , ppr subst'])
+ text "old substitution:" , ppr subst,
+ text "new substitution:" , ppr subst'])
; return (subst `unionTCvSubst` subst', term')}
tidyTermTyVars :: GhcMonad m => Term -> m Term
diff --git a/testsuite/tests/ghci/scripts/T17431.hs b/testsuite/tests/ghci/scripts/T17431.hs
new file mode 100644
index 0000000000..78050576df
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17431.hs
@@ -0,0 +1,10 @@
+module T17431 (sort) where
+
+sort :: Ord a => [a] -> [a]
+sort [] = []
+sort (x:xs) = insert x (sort xs)
+
+insert :: Ord a => a -> [a] -> [a]
+insert x [] = [x]
+insert x (y:ys) | x < y = x:y:ys
+ | otherwise = y:(insert x ys)
diff --git a/testsuite/tests/ghci/scripts/T17431.script b/testsuite/tests/ghci/scripts/T17431.script
new file mode 100644
index 0000000000..a53dcf4214
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17431.script
@@ -0,0 +1,4 @@
+:l T17431
+:br 5
+sort [3,2,1]
+:force x xs _result
diff --git a/testsuite/tests/ghci/scripts/T17431.stdout b/testsuite/tests/ghci/scripts/T17431.stdout
new file mode 100644
index 0000000000..e6fa548b1a
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T17431.stdout
@@ -0,0 +1,11 @@
+Breakpoint 0 activated at T17431.hs:5:15-32
+Stopped in T17431.sort, T17431.hs:5:15-32
+_result :: [a] = _
+x :: a = _
+xs :: [a] = [_,_]
+*** Ignoring breakpoint
+*** Ignoring breakpoint
+*** Ignoring breakpoint
+x = 3
+xs = [2,1]
+_result = [1,2,3]
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index ae0e38cb4e..094f101abb 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -310,3 +310,4 @@ test('T16876', normal, ghci_script, ['T16876.script'])
test('T17345', normal, ghci_script, ['T17345.script'])
test('T17384', normal, ghci_script, ['T17384.script'])
test('T17403', normal, ghci_script, ['T17403.script'])
+test('T17431', normal, ghci_script, ['T17431.script'])