[commit: ghc] master: Save renamed syntax when signature merging. (b301f78)

git at git.haskell.org git at git.haskell.org
Fri Mar 17 08:48:40 UTC 2017


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

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

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

commit b301f78eee89726248cf2d142e005c6618dc839c
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Mon Mar 13 02:22:06 2017 -0700

    Save renamed syntax when signature merging.
    
    Summary:
    This is required to make Haddock work correctly.
    
    Comes with a Haddock submodule update for better rendering.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate
    
    Reviewers: bgamari, austin
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3335


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

b301f78eee89726248cf2d142e005c6618dc839c
 compiler/typecheck/TcBackpack.hs                   | 32 ++++++++++++++++++++++
 .../tests/backpack/should_fail/bkpfail35.stderr    |  4 ---
 utils/haddock                                      |  2 +-
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/compiler/typecheck/TcBackpack.hs b/compiler/typecheck/TcBackpack.hs
index 2b4b05c..6944286 100644
--- a/compiler/typecheck/TcBackpack.hs
+++ b/compiler/typecheck/TcBackpack.hs
@@ -495,7 +495,33 @@ mergeSignatures
     -- Note [Blank hsigs for all requirements]
     hsc_env <- getTopEnv
     dflags  <- getDynFlags
+
+    -- Copy over some things from the original TcGblEnv that
+    -- we want to preserve
+    updGblEnv (\env -> env {
+        -- Renamed imports/declarations are often used
+        -- by programs that use the GHC API, e.g., Haddock.
+        -- These won't get filled by the merging process (since
+        -- we don't actually rename the parsed module again) so
+        -- we need to take them directly from the previous
+        -- typechecking.
+        --
+        -- NB: the export declarations aren't in their final
+        -- form yet.  We'll fill those in when we reprocess
+        -- the export declarations.
+        tcg_rn_imports = tcg_rn_imports orig_tcg_env,
+        tcg_rn_decls   = tcg_rn_decls   orig_tcg_env,
+        -- Annotations
+        tcg_ann_env    = tcg_ann_env    orig_tcg_env,
+        -- Documentation header
+        tcg_doc_hdr    = tcg_doc_hdr orig_tcg_env
+        -- tcg_dus?
+        -- tcg_th_used           = tcg_th_used orig_tcg_env,
+        -- tcg_th_splice_used    = tcg_th_splice_used orig_tcg_env
+        -- tcg_th_top_level_locs = tcg_th_top_level_locs orig_tcg_env
+       }) $ do
     tcg_env <- getGblEnv
+
     let outer_mod = tcg_mod tcg_env
         inner_mod = tcg_semantic_mod tcg_env
         mod_name = moduleName (tcg_mod tcg_env)
@@ -608,6 +634,7 @@ mergeSignatures
     (mb_lies, _) <- exports_from_avail mb_exports rdr_env
                         (tcg_imports tcg_env) (tcg_semantic_mod tcg_env)
 
+    {- -- NB: This is commented out, because warns above is disabled.
     -- If you tried to explicitly export an identifier that has a warning
     -- attached to it, that's probably a mistake.  Warn about it.
     case mb_lies of
@@ -620,9 +647,14 @@ mergeSignatures
                     text "Exported identifier" <+> quotes (ppr n) <+> text "will cause warnings if used.",
                     parens (text "To suppress this warning, remove" <+> quotes (ppr n) <+> text "from the export list of this signature.")
                     ]
+    -}
 
     failIfErrsM
 
+    -- Save the exports
+    setGblEnv tcg_env { tcg_rn_exports = mb_lies } $ do
+    tcg_env <- getGblEnv
+
     -- STEP 4: Rename the interfaces
     ext_ifaces <- forM thinned_ifaces $ \((IndefModule iuid _), ireq_iface) ->
         tcRnModIface (indefUnitIdInsts iuid) (Just nsubst) ireq_iface
diff --git a/testsuite/tests/backpack/should_fail/bkpfail35.stderr b/testsuite/tests/backpack/should_fail/bkpfail35.stderr
index 6b21317..cbb2152 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail35.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail35.stderr
@@ -3,10 +3,6 @@
   [2 of 2] Compiling B                ( p/B.hs, nothing )
 [2 of 4] Processing q
   [1 of 1] Compiling A[sig]           ( q/A.hsig, nothing )
-
-bkpfail35.bkp:8:18: warning:
-    Exported identifier ‘x’ will cause warnings if used.
-    (To suppress this warning, remove ‘x’ from the export list of this signature.)
 [3 of 4] Processing aimpl
   Instantiating aimpl
   [1 of 1] Compiling A                ( aimpl/A.hs, bkpfail35.out/aimpl/A.o )
diff --git a/utils/haddock b/utils/haddock
index af9c09f..bf3c4d7 160000
--- a/utils/haddock
+++ b/utils/haddock
@@ -1 +1 @@
-Subproject commit af9c09feac6fbecc50140f3aac1bb58888addc63
+Subproject commit bf3c4d72a0fda38561376eac7eda216158783267



More information about the ghc-commits mailing list