Commit 8e9ad240 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Setup more error context for Backpack operations.


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: bgamari, simonpj, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3101
parent a4ccd330
......@@ -364,7 +364,6 @@ formatErrDoc dflags (ErrDoc important context supplementary)
msgs = filter (not . null) $ map (filter (not . Outputable.isEmpty dflags))
[important, context, supplementary]
starred = (bullet<+>) . vcat
bullet = text $ if DynFlags.useUnicode dflags then "•" else "*"
pprErrMsgBagWithLoc :: Bag ErrMsg -> [SDoc]
pprErrMsgBagWithLoc bag = [ pprLocErrMsg item | item <- sortMsgBag Nothing bag ]
......
......@@ -316,10 +316,7 @@ checkUnitId uid = do
-- (because we FORCE things to be merged in), so don't check them
when (not (isHoleModule mod)) $ do
checkUnitId (moduleUnitId mod)
_ <- addErrCtxt (text "while checking that" <+> ppr mod
<+> text "implements signature" <+> ppr mod_name <+> text "in"
<+> ppr uid) $
mod `checkImplements` IndefModule indef mod_name
_ <- mod `checkImplements` IndefModule indef mod_name
return ()
_ -> return () -- if it's hashed, must be well-typed
......@@ -472,6 +469,15 @@ inheritedSigPvpWarning =
-- logically "implicit" entities are defined indirectly in an interface
-- file. #13151 gives a proposal to make these *truly* implicit.
merge_msg :: ModuleName -> [IndefModule] -> SDoc
merge_msg mod_name [] =
text "while checking the local signature" <+> ppr mod_name <+>
text "for consistency"
merge_msg mod_name reqs =
hang (text "while merging the signatures from" <> colon)
2 (vcat [ bullet <+> ppr req | req <- reqs ] $$
bullet <+> text "...and the local signature for" <+> ppr mod_name)
-- | Given a local 'ModIface', merge all inherited requirements
-- from 'requirementMerges' into this signature, producing
-- a final 'TcGblEnv' that matches the local signature and
......@@ -487,10 +493,13 @@ mergeSignatures hsmod lcl_iface0 = do
let outer_mod = tcg_mod tcg_env
inner_mod = tcg_semantic_mod tcg_env
mb_exports = hsmodExports (unLoc (hpm_module hsmod))
mod_name = moduleName (tcg_mod tcg_env)
-- STEP 1: Figure out all of the external signature interfaces
-- we are going to merge in.
let reqs = requirementMerges dflags (moduleName (tcg_mod tcg_env))
let reqs = requirementMerges dflags mod_name
addErrCtxt (merge_msg mod_name reqs) $ do
-- STEP 2: Read in the RAW forms of all of these interfaces
ireq_ifaces0 <- forM reqs $ \(IndefModule iuid mod_name) ->
......@@ -746,11 +755,18 @@ tcRnInstantiateSignature hsc_env this_mod real_loc =
exportOccs :: [AvailInfo] -> [OccName]
exportOccs = concatMap (map occName . availNames)
impl_msg :: Module -> IndefModule -> SDoc
impl_msg impl_mod (IndefModule req_uid req_mod_name) =
text "while checking that" <+> ppr impl_mod <+>
text "implements signature" <+> ppr req_mod_name <+>
text "in" <+> ppr req_uid
-- | Check if module implements a signature. (The signature is
-- always un-hashed, which is why its components are specified
-- explicitly.)
checkImplements :: Module -> IndefModule -> TcRn TcGblEnv
checkImplements impl_mod (IndefModule uid mod_name) = do
checkImplements impl_mod req_mod@(IndefModule uid mod_name) =
addErrCtxt (impl_msg impl_mod req_mod) $ do
let insts = indefUnitIdInsts uid
-- STEP 1: Load the implementing interface, and make a RdrEnv
......
......@@ -29,7 +29,7 @@ module Outputable (
semi, comma, colon, dcolon, space, equals, dot, vbar,
arrow, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt,
lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore,
blankLine, forAllLit, kindStar,
blankLine, forAllLit, kindStar, bullet,
(<>), (<+>), hcat, hsep,
($$), ($+$), vcat,
sep, cat,
......@@ -635,12 +635,21 @@ forAllLit = unicodeSyntax (char '∀') (text "forall")
kindStar :: SDoc
kindStar = unicodeSyntax (char '★') (char '*')
bullet :: SDoc
bullet = unicode (char '•') (char '*')
unicodeSyntax :: SDoc -> SDoc -> SDoc
unicodeSyntax unicode plain = sdocWithDynFlags $ \dflags ->
if useUnicode dflags && useUnicodeSyntax dflags
then unicode
else plain
unicode :: SDoc -> SDoc -> SDoc
unicode unicode plain = sdocWithDynFlags $ \dflags ->
if useUnicode dflags
then unicode
else plain
nest :: Int -> SDoc -> SDoc
-- ^ Indent 'SDoc' some specified amount
(<>) :: SDoc -> SDoc -> SDoc
......
q/H.hsig:2:1: error:
Identifier ‘x’ has conflicting definitions in the module
and its hsig file
Main module: x :: ghc-prim-0.5.0.0:GHC.Types.Int
Hsig file: x :: ghc-prim-0.5.0.0:GHC.Types.Bool
The two types are different
• Identifier ‘x’ has conflicting definitions in the module
and its hsig file
Main module: x :: ghc-prim-0.5.0.0:GHC.Types.Int
Hsig file: x :: ghc-prim-0.5.0.0:GHC.Types.Bool
The two types are different
• while merging the signatures from:
• z-bkpcabal01-z-p-0.1.0.0[H=<H>]:H
• ...and the local signature for H
......@@ -11,7 +11,9 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
bkpfail01.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/../H.hi:1:1: error:
‘H’ is exported by the hsig file, but not exported the module ‘q:H’
• ‘H’ is exported by the hsig file, but not exported the module ‘q:H’
• while checking that q:H implements signature H in p[H=q:H]
bkpfail01.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/../H.hi:1:1: error:
‘H’ is exported by the hsig file, but not exported the module ‘q:H’
• ‘H’ is exported by the hsig file, but not exported the module ‘q:H’
• while checking that q:H implements signature H in p[H=q:H]
......@@ -12,5 +12,6 @@
[2 of 2] Compiling M2[sig] ( q/M2.hsig, nothing )
bkpfail03.bkp:3:9: error:
The hsig file (re)exports ‘M1.M’
but the implementing module exports a different identifier ‘M2.M’
• The hsig file (re)exports ‘M1.M’
but the implementing module exports a different identifier ‘M2.M’
• while checking that m2:M2 implements signature M2 in q[M2=m2:M2]
......@@ -6,10 +6,14 @@
[1 of 2] Compiling A[sig] ( r/A.hsig, nothing )
bkpfail04.bkp:7:9: error:
Type constructor ‘A’ has conflicting definitions in the module
and its hsig file
Main module: data A = A {foo :: GHC.Types.Int}
Hsig file: data A = A {bar :: GHC.Types.Bool}
The constructors do not match:
The record label lists for ‘A’ differ
The types for ‘A’ differ
• Type constructor ‘A’ has conflicting definitions in the module
and its hsig file
Main module: data A = A {foo :: GHC.Types.Int}
Hsig file: data A = A {bar :: GHC.Types.Bool}
The constructors do not match:
The record label lists for ‘A’ differ
The types for ‘A’ differ
• while merging the signatures from:
• p[A=<A>]:A
• q[A=<A>]:A
• ...and the local signature for A
......@@ -18,4 +18,5 @@
[1 of 1] Compiling H[sig] ( h/H.hsig, bkpfail05.out/h/h-5FYQgnNkfSvBT5yogOxPpf/H.o )
bkpfail05.out/h/h-5FYQgnNkfSvBT5yogOxPpf/../H.hi:1:1: error:
‘T1’ is exported by the hsig file, but not exported the module ‘h-impl:H’
• ‘T1’ is exported by the hsig file, but not exported the module ‘h-impl:H’
• while checking that h-impl:H implements signature H in h[H=h-impl:H]
......@@ -12,8 +12,9 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail06.out/p/p-IueY0RdHDM2I4k0mLZuqM0/H.o )
bkpfail06.bkp:10:9: error:
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: data T = T GHC.Types.Bool
Hsig file: data T = T GHC.Types.Int
The constructors do not match: The types for ‘T’ differ
• Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: data T = T GHC.Types.Bool
Hsig file: data T = T GHC.Types.Int
The constructors do not match: The types for ‘T’ differ
• while checking that qimpl:H implements signature H in p[H=qimpl:H]
......@@ -10,15 +10,17 @@
[1 of 1] Compiling H[sig] ( p/H.hsig, bkpfail10.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
bkpfail10.bkp:8:9: error:
Type constructor ‘H’ has conflicting definitions in the module
and its hsig file
Main module: data H a = H a
Hsig file: skolem H
The types have different kinds
• Type constructor ‘H’ has conflicting definitions in the module
and its hsig file
Main module: data H a = H a
Hsig file: skolem H
The types have different kinds
• while checking that q:H implements signature H in p[H=q:H]
bkpfail10.bkp:10:9: error:
Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: f :: H a -> H a
Hsig file: f :: H -> H
The two types are different
• Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: f :: H a -> H a
Hsig file: f :: H -> H
The two types are different
• while checking that q:H implements signature H in p[H=q:H]
......@@ -11,7 +11,8 @@
[1 of 2] Compiling A[sig] ( sig/A.hsig, bkpfail11.out/sig/sig-HyoWTHt34SDIRGEX0vZ8iN/A.o )
bkpfail11.out/sig/sig-HyoWTHt34SDIRGEX0vZ8iN/../A.hi:1:1: error:
No instance for (GHC.Show.Show X)
arising when attempting to show that
instance [safe] GHC.Show.Show T -- Defined at bkpfail11.bkp:5:18
is provided by ‘mod:A’
• No instance for (GHC.Show.Show X)
arising when attempting to show that
instance [safe] GHC.Show.Show T -- Defined at bkpfail11.bkp:5:18
is provided by ‘mod:A’
• while checking that mod:A implements signature A in sig[A=mod:A]
......@@ -7,4 +7,5 @@
[1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail16.out/p/p-1OqLaT7dAn947wScQQKCw5/ShouldFail.o )
bkpfail16.out/p/p-1OqLaT7dAn947wScQQKCw5/../ShouldFail.hi:1:1: error:
‘Booly’ is exported by the hsig file, but not exported the module ‘Data.Bool’
• ‘Booly’ is exported by the hsig file, but not exported the module ‘Data.Bool’
• while checking that Data.Bool implements signature ShouldFail in p[ShouldFail=Data.Bool]
......@@ -7,9 +7,10 @@
[1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail17.out/p/p-2W6J7O3LvroH97zGxbPEGF/ShouldFail.o )
<no location info>: error:
Type constructor ‘Either’ has conflicting definitions in the module
and its hsig file
Main module: data Either a b = Left a | Right b
Hsig file: type role Either representational phantom phantom
data Either a b c = Left a
The types have different kinds
• Type constructor ‘Either’ has conflicting definitions in the module
and its hsig file
Main module: data Either a b = Left a | Right b
Hsig file: type role Either representational phantom phantom
data Either a b c = Left a
The types have different kinds
• while checking that Prelude implements signature ShouldFail in p[ShouldFail=Prelude]
......@@ -7,5 +7,6 @@
[1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail19.out/p/p-CfyUIAu1JTRCDuXEyGszXN/ShouldFail.o )
<no location info>: error:
The hsig file (re)exports ‘Data.STRef.Lazy.newSTRef’
but the implementing module exports a different identifier ‘GHC.STRef.newSTRef’
• The hsig file (re)exports ‘Data.STRef.Lazy.newSTRef’
but the implementing module exports a different identifier ‘GHC.STRef.newSTRef’
• while checking that Data.STRef implements signature ShouldFail in p[ShouldFail=Data.STRef]
......@@ -6,4 +6,8 @@
[1 of 1] Compiling B[sig] ( r/B.hsig, nothing )
bkpfail20.bkp:1:1: error:
While merging export lists, could not unify Data.STRef.Lazy.newSTRef with GHC.STRef.newSTRef
• While merging export lists, could not unify Data.STRef.Lazy.newSTRef with GHC.STRef.newSTRef
• while merging the signatures from:
• p[A=<B>]:A
• q[A=<B>]:A
• ...and the local signature for B
......@@ -10,5 +10,9 @@
[3 of 3] Compiling H3[sig] ( r/H3.hsig, nothing )
bkpfail21.bkp:1:1: error:
While merging export lists, could not unify {H1.T} with {H2.T}
Neither name variable originates from the current signature.
• While merging export lists, could not unify {H1.T} with {H2.T}
Neither name variable originates from the current signature.
• while merging the signatures from:
• p[A=<H1>,C=<H3>]:C
• q[B=<H2>,C=<H3>]:C
• ...and the local signature for H3
......@@ -14,7 +14,8 @@
[1 of 2] Compiling H2[sig] ( q/H2.hsig, bkpfail22.out/q/q-FjwGsuDQ5qiKUCvnEATUA9/H2.o )
bkpfail22.bkp:16:9: error:
Type constructor ‘S’ has conflicting definitions in the module
and its hsig file
Main module: type S = ()
Hsig file: type S = GHC.Types.Bool
• Type constructor ‘S’ has conflicting definitions in the module
and its hsig file
Main module: type S = ()
Hsig file: type S = GHC.Types.Bool
• while checking that badimpl:H2 implements signature H2 in q[H2=badimpl:H2]
......@@ -11,10 +11,11 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail23.out/p/p-6KeuBvYi0jvLWqVbkSAZMq/H.o )
bkpfail23.bkp:14:9: error:
Type constructor ‘F’ has conflicting definitions in the module
and its hsig file
Main module: type F a = ()
Hsig file: type role F phantom
skolem F a
Illegal parameterized type synonym in implementation of abstract data.
(Try eta reducing your type synonym so that it is nullary.)
• Type constructor ‘F’ has conflicting definitions in the module
and its hsig file
Main module: type F a = ()
Hsig file: type role F phantom
skolem F a
Illegal parameterized type synonym in implementation of abstract data.
(Try eta reducing your type synonym so that it is nullary.)
• while checking that h:H implements signature H in p[H=h:H]
......@@ -16,7 +16,8 @@ bkpfail25.bkp:7:18: warning: [-Wmissing-methods (in -Wdefault)]
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail25.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
bkpfail25.bkp:12:9: error:
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type T a = a
Hsig file: skolem T a
• Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type T a = a
Hsig file: skolem T a
• while checking that q:H implements signature H in p[H=q:H]
......@@ -11,9 +11,10 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail26.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
bkpfail26.bkp:15:9: error:
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type T a = [a]
Hsig file: skolem T a
Illegal parameterized type synonym in implementation of abstract data.
(Try eta reducing your type synonym so that it is nullary.)
• Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type T a = [a]
Hsig file: skolem T a
Illegal parameterized type synonym in implementation of abstract data.
(Try eta reducing your type synonym so that it is nullary.)
• while checking that q:H implements signature H in p[H=q:H]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment