[commit: ghc] master, wip/rejig-stages: Remove the GHCi debugger's panicking isUnliftedType check (8162eab)
git at git.haskell.org
git at git.haskell.org
Fri Mar 15 19:06:25 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branches: master,wip/rejig-stages
Link : http://ghc.haskell.org/trac/ghc/changeset/8162eab27101cddb0c822347300640f07110379a/ghc
>---------------------------------------------------------------
commit 8162eab27101cddb0c822347300640f07110379a
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Tue Mar 12 10:06:38 2019 -0400
Remove the GHCi debugger's panicking isUnliftedType check
The GHCi debugger has never been that robust in the face of
higher-rank types, or even types that are _interally_ higher-rank,
such as the types of many class methods (e.g., `fmap`). In GHC 8.2,
however, things became even worse, as the debugger would start to
_panic_ when a user tries passing the name of a higher-rank thing
to `:print`. This all ties back to a strange `isUnliftedType` check
in `Debugger` that was mysteriously added 11 years ago
(in commit 4d71f5ee6dbbfedb4a55767e4375f4c0aadf70bb) with no
explanation whatsoever.
After some experimentation, no one is quite sure what this
`isUnliftedType` check is actually accomplishing. The test suite
still passes if it's removed, and I am unable to observe any
differences in debugger before even with data types that _do_ have
fields of unlifted types (e.g., `data T = MkT Int#`). Given that
this is actively causing problems (see #14828), the prudent thing
to do seems to be just removing this `isUnliftedType` check, and
waiting to see if anyone shouts about it. This patch accomplishes
just that.
Note that this patch fix the underlying issues behind #14828, as the
debugger will still print unhelpful info if you try this:
```
λ> f :: (forall a. a -> a) -> b -> b; f g x = g x
λ> :print f
f = (_t1::t1)
```
But fixing this will require much more work, so let's start with the
simple stuff for now.
>---------------------------------------------------------------
8162eab27101cddb0c822347300640f07110379a
compiler/ghci/Debugger.hs | 3 +--
testsuite/tests/ghci/scripts/T14828.script | 4 ++++
testsuite/tests/ghci/scripts/T14828.stdout | 12 ++++++++++++
testsuite/tests/ghci/scripts/all.T | 2 +-
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs
index 38d1588..888d00e 100644
--- a/compiler/ghci/Debugger.hs
+++ b/compiler/ghci/Debugger.hs
@@ -77,8 +77,7 @@ pprintClosureCommand bindThings force str = do
let id' = id `setIdType` substTy subst (idType id)
term_ <- GHC.obtainTermFromId maxBound force id'
term <- tidyTermTyVars term_
- term' <- if bindThings &&
- (not (isUnliftedType (termType term)))
+ term' <- if bindThings
then bindSuspensions term
else return term
-- Before leaving, we compare the type obtained to see if it's more specific
diff --git a/testsuite/tests/ghci/scripts/T14828.script b/testsuite/tests/ghci/scripts/T14828.script
index bb0650f..59d616a 100644
--- a/testsuite/tests/ghci/scripts/T14828.script
+++ b/testsuite/tests/ghci/scripts/T14828.script
@@ -16,3 +16,7 @@
:m + Data.List
:p foldl'
+
+:set -XRankNTypes
+f :: (forall a. a -> a) -> b -> b; f g x = g x
+:p f
diff --git a/testsuite/tests/ghci/scripts/T14828.stdout b/testsuite/tests/ghci/scripts/T14828.stdout
new file mode 100644
index 0000000..3ef2e60
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/T14828.stdout
@@ -0,0 +1,12 @@
+foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
+foldl = (_t1::t1)
+fmap :: Functor f => (a -> b) -> f a -> f b
+fmap = (_t2::t1)
+return :: Monad m => a -> m a
+return = (_t3::t1)
+pure :: Applicative f => a -> f a
+pure = (_t4::t1)
+mempty = (_t5::Monoid a => a)
+mappend = (_t6::Monoid a => a -> a -> a)
+foldl' = (_t7::t1)
+f = (_t8::t1)
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 4eea5c3..115dfc5 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -292,5 +292,5 @@ test('T15941', normal, ghci_script, ['T15941.script'])
test('T16030', normal, ghci_script, ['T16030.script'])
test('T11606', normal, ghci_script, ['T11606.script'])
test('T16089', normal, ghci_script, ['T16089.script'])
-test('T14828', expect_broken(14828), ghci_script, ['T14828.script'])
+test('T14828', normal, ghci_script, ['T14828.script'])
test('T16376', normal, ghci_script, ['T16376.script'])
More information about the ghc-commits
mailing list