diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-10-10 12:01:14 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-10-08 00:20:34 -0700 |
commit | 00b530d5402aaa37e4085ecdcae0ae54454736c1 (patch) | |
tree | 2d2963db4abdbcba9c12aea13a26e29e718e4778 /compiler/rename | |
parent | 887485a45ae55e81b26b6412b6f9dcf6a497f044 (diff) | |
download | haskell-00b530d5402aaa37e4085ecdcae0ae54454736c1.tar.gz |
The Backpack patch.
Summary:
This patch implements Backpack for GHC. It's a big patch but I've tried quite
hard to keep things, by-in-large, self-contained.
The user facing specification for Backpack can be found at:
https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst
A guide to the implementation can be found at:
https://github.com/ezyang/ghc-proposals/blob/backpack-impl/proposals/0000-backpack-impl.rst
Has a submodule update for Cabal, as well as a submodule update
for filepath to handle more strict checking of cabal-version.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin, simonmar, bgamari, goldfire
Subscribers: thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D1482
Diffstat (limited to 'compiler/rename')
-rw-r--r-- | compiler/rename/RnEnv.hs | 40 | ||||
-rw-r--r-- | compiler/rename/RnNames.hs | 9 |
2 files changed, 19 insertions, 30 deletions
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs index b1cb7fe064..d41e9ef48e 100644 --- a/compiler/rename/RnEnv.hs +++ b/compiler/rename/RnEnv.hs @@ -208,40 +208,16 @@ newTopSrcBinder (L loc rdr_name) -- module name, we we get a confusing "M.T is not in scope" error later ; stage <- getStage - ; env <- getGblEnv ; if isBrackStage stage then -- We are inside a TH bracket, so make an *Internal* name -- See Note [Top-level Names in Template Haskell decl quotes] in RnNames do { uniq <- newUnique ; return (mkInternalName uniq (rdrNameOcc rdr_name) loc) } - else case tcg_impl_rdr_env env of - Just gr -> - -- We're compiling --sig-of, so resolve with respect to this - -- module. - -- See Note [Signature parameters in TcGblEnv and DynFlags] - do { case lookupGlobalRdrEnv gr (rdrNameOcc rdr_name) of - -- Be sure to override the loc so that we get accurate - -- information later - [GRE{ gre_name = n }] -> do - -- NB: Just adding this line will not work: - -- addUsedGRE True gre - -- see Note [Signature lazy interface loading] for - -- more details. - return (setNameLoc n loc) - _ -> do - { -- NB: cannot use reportUnboundName rdr_name - -- because it looks up in the wrong RdrEnv - -- ToDo: more helpful error messages - ; addErr (unknownNameErr (pprNonVarNameSpace - (occNameSpace (rdrNameOcc rdr_name))) rdr_name) - ; return (mkUnboundNameRdr rdr_name) - } - } - Nothing -> - -- Normal case + else do { this_mod <- getModule ; traceRn (text "newTopSrcBinder" <+> (ppr this_mod $$ ppr rdr_name $$ ppr loc)) - ; newGlobalBinder this_mod (rdrNameOcc rdr_name) loc } } + ; newGlobalBinder this_mod (rdrNameOcc rdr_name) loc } + } {- ********************************************************* @@ -1216,6 +1192,14 @@ data HsSigCtxt | RoleAnnotCtxt NameSet -- A role annotation, with the names of all types -- in the group +instance Outputable HsSigCtxt where + ppr (TopSigCtxt ns) = text "TopSigCtxt" <+> ppr ns + ppr (LocalBindCtxt ns) = text "LocalBindCtxt" <+> ppr ns + ppr (ClsDeclCtxt n) = text "ClsDeclCtxt" <+> ppr n + ppr (InstDeclCtxt ns) = text "InstDeclCtxt" <+> ppr ns + ppr (HsBootCtxt ns) = text "HsBootCtxt" <+> ppr ns + ppr (RoleAnnotCtxt ns) = text "RoleAnnotCtxt" <+> ppr ns + lookupSigOccRn :: HsSigCtxt -> Sig RdrName -> Located RdrName -> RnM (Located Name) @@ -1398,7 +1382,7 @@ lookupFixity is a bit strange. * Nested local fixity decls are put in the local fixity env, which we find with getFixtyEnv -* Imported fixities are found in the HIT or PIT +* Imported fixities are found in the PIT * Top-level fixity decls in this module may be for Names that are either Global (constructors, class operations) diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs index 6b4942f41f..e1258a3d0d 100644 --- a/compiler/rename/RnNames.hs +++ b/compiler/rename/RnNames.hs @@ -12,6 +12,7 @@ module RnNames ( gresFromAvails, calculateAvails, reportUnusedNames, + plusAvail, checkConName ) where @@ -153,7 +154,10 @@ with yes we have gone with no for now. rnImports :: [LImportDecl RdrName] -> RnM ([LImportDecl Name], GlobalRdrEnv, ImportAvails, AnyHpcUsage) rnImports imports = do - this_mod <- getModule + tcg_env <- getGblEnv + -- NB: want an identity module here, because it's OK for a signature + -- module to import from its implementor + let this_mod = tcg_mod tcg_env let (source, ordinary) = partition is_source_import imports is_source_import d = ideclSource (unLoc d) stuff1 <- mapAndReportM (rnImportDecl this_mod) ordinary @@ -811,7 +815,8 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items)) -- NB: the AvailTC can have fields as well as data constructors (Trac #12127) combine (name1, a1@(AvailTC p1 _ _), mp1) (name2, a2@(AvailTC p2 _ _), mp2) - = ASSERT( name1 == name2 && isNothing mp1 && isNothing mp2 ) + = ASSERT2( name1 == name2 && isNothing mp1 && isNothing mp2 + , ppr name1 <+> ppr name2 <+> ppr mp1 <+> ppr mp2 ) if p1 == name1 then (name1, a1, Just p2) else (name1, a2, Just p1) combine x y = pprPanic "filterImports/combine" (ppr x $$ ppr y) |