[commit: ghc] master: Fix panic on :kind _ in GHCi (Trac #9879) (6eb86a5)

git at git.haskell.org git at git.haskell.org
Tue Dec 23 14:47:42 UTC 2014


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

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

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

commit 6eb86a56135a9274d2c958a2ccf4df510c9dab86
Author: Thomas Winant <thomas.winant at cs.kuleuven.be>
Date:   Tue Dec 23 08:48:15 2014 -0600

    Fix panic on :kind _ in GHCi (Trac #9879)
    
    Summary:
    Running `:kind _` in GHCi produced a panic, fix it by extracting the
    wildcards. Now, `:kind _` produces `_ :: k0`. Unfortunately, a `0` is
    added after the kind is tidied and I haven't found a way to get rid of
    it...
    
    This does not fix the other panic involving TemplateHaskell mentioned
    in #9879.
    
    Test Plan: new test GHCiWildcardKind should pass
    
    Reviewers: austin, simonpj
    
    Reviewed By: austin
    
    Subscribers: simonpj, carter, thomie, monoidal
    
    Differential Revision: https://phabricator.haskell.org/D572
    
    GHC Trac Issues: #9879


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

6eb86a56135a9274d2c958a2ccf4df510c9dab86
 compiler/typecheck/TcRnDriver.hs                                  | 8 ++++++--
 testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.script   | 3 +++
 testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout   | 2 ++
 .../should_compile => partial-sigs/should_run}/Makefile           | 0
 testsuite/tests/partial-sigs/should_run/all.T                     | 1 +
 5 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index b464400..f640039 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -1792,12 +1792,16 @@ tcRnType :: HscEnv
 tcRnType hsc_env normalise rdr_type
   = runTcInteractive hsc_env $
     setXOptM Opt_PolyKinds $   -- See Note [Kind-generalise in tcRnType]
-    do { (rn_type, _fvs) <- rnLHsType GHCiCtx rdr_type
+    do { (wcs, rdr_type') <- extractWildcards rdr_type
+       ; (rn_type, wcs)   <- bindLocatedLocalsRn wcs $ \wcs_new -> do {
+       ; (rn_type, _fvs)  <- rnLHsType GHCiCtx rdr_type'
        ; failIfErrsM
+       ; return (rn_type, wcs_new) }
 
         -- Now kind-check the type
         -- It can have any rank or kind
-       ; ty <- tcHsSigType GhciCtxt rn_type ;
+       ; nwc_tvs <- mapM newWildcardVarMetaKind wcs
+       ; ty <- tcExtendTyVarEnv nwc_tvs $ tcHsSigType GhciCtxt rn_type
 
        ; ty' <- if normalise
                 then do { fam_envs <- tcGetFamInstEnvs
diff --git a/testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.script b/testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.script
new file mode 100644
index 0000000..a3f9b35
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.script
@@ -0,0 +1,3 @@
+:kind _
+:kind Maybe _
+
diff --git a/testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout b/testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout
new file mode 100644
index 0000000..e1b2bd3
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_run/GHCiWildcardKind.stdout
@@ -0,0 +1,2 @@
+_ :: k0
+Maybe _ :: *
diff --git a/testsuite/tests/annotations/should_compile/Makefile b/testsuite/tests/partial-sigs/should_run/Makefile
similarity index 100%
copy from testsuite/tests/annotations/should_compile/Makefile
copy to testsuite/tests/partial-sigs/should_run/Makefile
diff --git a/testsuite/tests/partial-sigs/should_run/all.T b/testsuite/tests/partial-sigs/should_run/all.T
new file mode 100644
index 0000000..0ca1b61
--- /dev/null
+++ b/testsuite/tests/partial-sigs/should_run/all.T
@@ -0,0 +1 @@
+test('GHCiWildcardKind', normal, ghci_script, ['GHCiWildcardKind.script'])



More information about the ghc-commits mailing list