summaryrefslogtreecommitdiff
path: root/compiler/main/GhcMake.hs
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/main/GhcMake.hs
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/main/GhcMake.hs')
-rw-r--r--compiler/main/GhcMake.hs18
1 files changed, 18 insertions, 0 deletions
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))