summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2016-12-08 19:32:37 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2016-12-12 23:09:55 -0800
commit24f6bec94411aa6c39a2c94ce5154ffe96ae330f (patch)
tree594b5f74d9889751abc5e959109e78c2fd789eb3 /compiler
parent8f6d241a74efa6f6280689a9b14c36c6a9f4c231 (diff)
downloadhaskell-24f6bec94411aa6c39a2c94ce5154ffe96ae330f.tar.gz
Sanity check if we pick up an hsig file without -instantiated-with.
Summary: Previously we would just let compilation proceed along until we tried to pull up the Module for the hsig file, and get main:A instead of <A>, and get a mysterious error. Check for this earlier! Fixes #12955. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2815 GHC Trac Issues: #12955
Diffstat (limited to 'compiler')
-rw-r--r--compiler/basicTypes/Module.hs15
-rw-r--r--compiler/main/GhcMake.hs18
2 files changed, 20 insertions, 13 deletions
diff --git a/compiler/basicTypes/Module.hs b/compiler/basicTypes/Module.hs
index 78abf2188d..75ff67d54d 100644
--- a/compiler/basicTypes/Module.hs
+++ b/compiler/basicTypes/Module.hs
@@ -690,21 +690,10 @@ instance Outputable IndefUnitId where
ppr cid <>
(if not (null insts) -- pprIf
then
- -- TODO: Print an instantiation if (1) we would not have qualified
- -- the module and (2) the module name and module agree
- let -- is_wanted (mod_name, mod) = qualModule sty mod
- -- || mod_name /= moduleName mod
- (wanted, unwanted) = (insts, [])
- {-
- -- This was more annoying than helpful
- | debugStyle sty = (insts, [])
- | otherwise = partition is_wanted insts
- -}
- in brackets (hsep
+ brackets (hcat
(punctuate comma $
[ ppr modname <> text "=" <> ppr m
- | (modname, m) <- wanted] ++
- if not (null unwanted) then [text "..."] else []))
+ | (modname, m) <- insts]))
else empty)
where
cid = indefUnitIdComponentId uid
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 2340f3f46e..aa50c3afbc 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -2049,6 +2049,24 @@ summariseModule hsc_env old_summary_map is_boot (L loc wanted_mod)
$$ text "Saw:" <+> quotes (ppr mod_name)
$$ text "Expected:" <+> quotes (ppr wanted_mod)
+ when (hsc_src == HsigFile && isNothing (lookup mod_name (thisUnitIdInsts dflags))) $
+ let suggested_instantiated_with =
+ hcat (punctuate comma $
+ [ ppr k <> text "=" <> ppr v
+ | (k,v) <- ((mod_name, mkHoleModule mod_name)
+ : thisUnitIdInsts dflags)
+ ])
+ in throwOneError $ mkPlainErrMsg dflags' mod_loc $
+ text "Unexpected signature:" <+> quotes (ppr mod_name)
+ $$ if gopt Opt_BuildingCabalPackage dflags
+ then parens (text "Try adding" <+> quotes (ppr mod_name)
+ <+> text "to the"
+ <+> quotes (text "signatures")
+ <+> text "field in your Cabal file.")
+ else parens (text "Try passing -instantiated-with=\"" <>
+ suggested_instantiated_with <> text "\"" $$
+ text "replacing <" <> ppr mod_name <> text "> as necessary.")
+
-- Find the object timestamp, and return the summary
obj_timestamp <-
if isObjectTarget (hscTarget (hsc_dflags hsc_env))