From 24f6bec94411aa6c39a2c94ce5154ffe96ae330f Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 8 Dec 2016 19:32:37 -0800 Subject: 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 , and get a mysterious error. Check for this earlier! Fixes #12955. Signed-off-by: Edward Z. Yang Test Plan: validate Reviewers: simonpj, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2815 GHC Trac Issues: #12955 --- compiler/main/GhcMake.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'compiler/main') 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)) -- cgit v1.2.1