summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2017-03-13 02:22:06 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2017-03-17 01:48:02 -0700
commitb301f78eee89726248cf2d142e005c6618dc839c (patch)
treed52f1862c162d7e36b265536547845de46c87e82
parentbc21ea0ac849916bd444a1d935d44a110b815e00 (diff)
downloadhaskell-b301f78eee89726248cf2d142e005c6618dc839c.tar.gz
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@cs.stanford.edu> Test Plan: validate Reviewers: bgamari, austin Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3335
-rw-r--r--compiler/typecheck/TcBackpack.hs32
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail35.stderr4
m---------utils/haddock0
3 files changed, 32 insertions, 4 deletions
diff --git a/compiler/typecheck/TcBackpack.hs b/compiler/typecheck/TcBackpack.hs
index 2b4b05cd9b..694428612e 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 6b2131768e..cbb2152f7f 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
-Subproject af9c09feac6fbecc50140f3aac1bb58888addc6
+Subproject bf3c4d72a0fda38561376eac7eda21615878326