Commit 617d57d1 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Reduce qualification in error messages from signature matching.



Summary:
Previously, we always qualified names, even if they were defined
in the modules we were matching.  Adding the exports of the implementing
module into the RdrEnv greatly reduces the amount of qualification
(although we still can't qualify things that the signature *imported*.)
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2803
parent 62332f36
......@@ -553,6 +553,13 @@ checkImplements impl_mod (IndefModule uid mod_name) = do
let avails = calculateAvails dflags
impl_iface False{- safe -} False{- boot -}
updGblEnv (\tcg_env -> tcg_env {
-- Setting tcg_rdr_env to treat all exported entities from
-- the implementing module as in scope improves error messages,
-- as it reduces the amount of qualification we need. Unfortunately,
-- we still end up qualifying references to external modules
-- (see bkpfail07 for an example); we'd need to record more
-- information in ModIface to solve this.
tcg_rdr_env = tcg_rdr_env tcg_env `plusGlobalRdrEnv` impl_gr,
tcg_imports = tcg_imports tcg_env `plusImportAvails` avails
}) $ do
......
......@@ -12,8 +12,8 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail06.out/p/p-IueY0RdHDM2I4k0mLZuqM0/H.o )
bkpfail06.bkp:10:9: error:
Type constructor ‘qimpl:T.T’ has conflicting definitions in the module
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: data qimpl:T.T = qimpl:T.T GHC.Types.Bool
Hsig file: data qimpl:T.T = qimpl:T.T GHC.Types.Int
The constructors do not match: The types for ‘qimpl:T.T’ differ
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
......@@ -8,9 +8,9 @@
[1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
bkpfail07.bkp:6:9: error:
• Type constructor ‘h[A=<A>]:T.T’ has conflicting definitions in the module
• Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: data h[A=<A>]:T.T = h[A=<A>]:T.T GHC.Types.Bool
Hsig file: data h[A=<A>]:T.T = h[A=<A>]:T.T GHC.Types.Int
The constructors do not match: The types for ‘h[A=<A>]:T.T’ differ
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 h[A=<A>]:H implements signature H in p[H=h[A=<A>]:H]
......@@ -10,15 +10,15 @@
[1 of 1] Compiling H[sig] ( p/H.hsig, bkpfail10.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
bkpfail10.bkp:8:9: error:
Type constructor ‘q:H.H’ has conflicting definitions in the module
Type constructor ‘H’ has conflicting definitions in the module
and its hsig file
Main module: data q:H.H a = q:H.H a
Hsig file: skolem q:H.H
Main module: data H a = H a
Hsig file: skolem H
The types have different kinds
bkpfail10.bkp:10:9: error:
Identifier ‘q:H.f’ has conflicting definitions in the module
Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: q:H.f :: q:H.H a -> q:H.H a
Hsig file: q:H.f :: q:H.H -> q:H.H
Main module: f :: H a -> H a
Hsig file: f :: H -> H
The two types are different
......@@ -11,8 +11,7 @@
[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 mod:A.X)
No instance for (GHC.Show.Show X)
arising when attempting to show that
instance [safe] GHC.Show.Show mod:A.T
-- Defined at bkpfail11.bkp:5:18
instance [safe] GHC.Show.Show T -- Defined at bkpfail11.bkp:5:18
is provided by ‘mod:A’
......@@ -7,9 +7,9 @@
[3 of 3] Processing r
bkpfail12.bkp:8:9: error:
• Identifier ‘Q.f’ has conflicting definitions in the module
• Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: Q.f :: GHC.Types.Bool
Hsig file: Q.f :: GHC.Types.Int
Main module: f :: GHC.Types.Bool
Hsig file: f :: GHC.Types.Int
The two types are different
• while checking that Q implements signature Q in p[Q=Q]
......@@ -7,9 +7,9 @@
[3 of 3] Processing r
bkpfail13.bkp:8:9: error:
• Identifier ‘q:QMe.f’ has conflicting definitions in the module
• Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: q:QMe.f :: GHC.Types.Bool
Hsig file: q:QMe.f :: GHC.Types.Int
Main module: f :: GHC.Types.Bool
Hsig file: f :: GHC.Types.Int
The two types are different
• while checking that q:QMe implements signature Q in p[Q=q:QMe]
......@@ -10,9 +10,9 @@
[3 of 3] Processing r
bkpfail14.bkp:9:9: error:
• Identifier ‘QMe.f’ has conflicting definitions in the module
• Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: QMe.f :: GHC.Types.Bool
Hsig file: QMe.f :: GHC.Types.Int
Main module: f :: GHC.Types.Bool
Hsig file: f :: GHC.Types.Int
The two types are different
• while checking that QMe implements signature Q in p[Q=QMe, Q2=Q2]
......@@ -9,9 +9,9 @@
[1 of 1] Compiling A[sig] ( r/A.hsig, nothing )
bkpfail15.bkp:8:9: error:
• Identifier ‘q:Q.f’ has conflicting definitions in the module
• Identifier ‘f’ has conflicting definitions in the module
and its hsig file
Main module: q:Q.f :: GHC.Types.Bool
Hsig file: q:Q.f :: GHC.Types.Int
Main module: f :: GHC.Types.Bool
Hsig file: f :: GHC.Types.Int
The two types are different
• while checking that q:Q implements signature Q in p[A=<A>, Q=q:Q]
......@@ -7,10 +7,9 @@
[1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail17.out/p/p-2W6J7O3LvroH97zGxbPEGF/ShouldFail.o )
<no location info>: error:
Type constructor ‘Data.Either.Either’ has conflicting definitions in the module
Type constructor ‘Either’ has conflicting definitions in the module
and its hsig file
Main module: data Data.Either.Either a b
= Data.Either.Left a | Data.Either.Right b
Hsig file: type role Data.Either.Either representational phantom phantom
data Data.Either.Either a b c = Data.Either.Left a
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
......@@ -14,7 +14,7 @@
[1 of 2] Compiling H2[sig] ( q/H2.hsig, bkpfail22.out/q/q-FjwGsuDQ5qiKUCvnEATUA9/H2.o )
bkpfail22.bkp:16:9: error:
Type constructor ‘badimpl:H2.S’ has conflicting definitions in the module
Type constructor ‘S’ has conflicting definitions in the module
and its hsig file
Main module: type badimpl:H2.S = ()
Hsig file: type badimpl:H2.S = GHC.Types.Bool
Main module: type S = ()
Hsig file: type S = GHC.Types.Bool
......@@ -11,10 +11,10 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail23.out/p/p-6KeuBvYi0jvLWqVbkSAZMq/H.o )
bkpfail23.bkp:14:9: error:
Type constructor ‘h:H.F’ has conflicting definitions in the module
Type constructor ‘F’ has conflicting definitions in the module
and its hsig file
Main module: type h:H.F a = ()
Hsig file: type role h:H.F phantom
skolem h:H.F a
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.)
......@@ -16,7 +16,7 @@ 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 ‘q:H.T’ has conflicting definitions in the module
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type q:H.T a = a
Hsig file: skolem q:H.T a
Main module: type T a = a
Hsig file: skolem T a
......@@ -11,9 +11,9 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail26.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
bkpfail26.bkp:15:9: error:
Type constructor ‘q:H.T’ has conflicting definitions in the module
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type q:H.T a = [a]
Hsig file: skolem q:H.T a
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.)
......@@ -11,8 +11,8 @@
[1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail27.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
bkpfail27.bkp:15:9: error:
Type constructor ‘q:H.T’ has conflicting definitions in the module
Type constructor ‘T’ has conflicting definitions in the module
and its hsig file
Main module: type q:H.T = q:H.F
Hsig file: skolem q:H.T
Main module: type T = F
Hsig file: skolem T
Illegal type family application in implementation of abstract data.
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