summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2016-12-07 23:07:19 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2016-12-08 15:03:18 -0800
commit617d57d1166d67148f28401fabaf88295f1d3f06 (patch)
tree4a7c6a19e5b0b6203f476f261104fb19cb49c645
parent62332f36b62431ddb9ab3c97365288c7d3fc2d39 (diff)
downloadhaskell-617d57d1166d67148f28401fabaf88295f1d3f06.tar.gz
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: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2803
-rw-r--r--compiler/typecheck/TcBackpack.hs7
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail06.stderr8
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail07.stderr8
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail10.stderr12
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail11.stderr5
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail12.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail13.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail14.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail15.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail17.stderr9
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail22.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail23.stderr8
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail25.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail26.stderr6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail27.stderr6
15 files changed, 55 insertions, 50 deletions
diff --git a/compiler/typecheck/TcBackpack.hs b/compiler/typecheck/TcBackpack.hs
index 7e7b30cf91..b6623cdbb7 100644
--- a/compiler/typecheck/TcBackpack.hs
+++ b/compiler/typecheck/TcBackpack.hs
@@ -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
diff --git a/testsuite/tests/backpack/should_fail/bkpfail06.stderr b/testsuite/tests/backpack/should_fail/bkpfail06.stderr
index 1fb5d5311f..c050944284 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail06.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail06.stderr
@@ -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
diff --git a/testsuite/tests/backpack/should_fail/bkpfail07.stderr b/testsuite/tests/backpack/should_fail/bkpfail07.stderr
index 8a2c3876bb..f8cf6b000a 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail07.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail07.stderr
@@ -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]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail10.stderr b/testsuite/tests/backpack/should_fail/bkpfail10.stderr
index 248ef6356a..27cbcdc889 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail10.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail10.stderr
@@ -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
diff --git a/testsuite/tests/backpack/should_fail/bkpfail11.stderr b/testsuite/tests/backpack/should_fail/bkpfail11.stderr
index 065a2e6ed4..c91d15f4e3 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail11.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail11.stderr
@@ -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’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail12.stderr b/testsuite/tests/backpack/should_fail/bkpfail12.stderr
index 224f23a86a..0526da438c 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail12.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail12.stderr
@@ -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]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail13.stderr b/testsuite/tests/backpack/should_fail/bkpfail13.stderr
index 34dbeb82c7..afd4474f35 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail13.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail13.stderr
@@ -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]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail14.stderr b/testsuite/tests/backpack/should_fail/bkpfail14.stderr
index bdccdee938..ddfddeeb91 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail14.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail14.stderr
@@ -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]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail15.stderr b/testsuite/tests/backpack/should_fail/bkpfail15.stderr
index 37d0f5d3a4..e761cb102e 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail15.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail15.stderr
@@ -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]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail17.stderr b/testsuite/tests/backpack/should_fail/bkpfail17.stderr
index 99cecef7dc..20528f5acc 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail17.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail17.stderr
@@ -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
diff --git a/testsuite/tests/backpack/should_fail/bkpfail22.stderr b/testsuite/tests/backpack/should_fail/bkpfail22.stderr
index 522985db39..66db5b6a7c 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail22.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail22.stderr
@@ -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
diff --git a/testsuite/tests/backpack/should_fail/bkpfail23.stderr b/testsuite/tests/backpack/should_fail/bkpfail23.stderr
index ac5fd06388..6681e24472 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail23.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail23.stderr
@@ -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.)
diff --git a/testsuite/tests/backpack/should_fail/bkpfail25.stderr b/testsuite/tests/backpack/should_fail/bkpfail25.stderr
index 1440948544..56b1c90ff0 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail25.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail25.stderr
@@ -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
diff --git a/testsuite/tests/backpack/should_fail/bkpfail26.stderr b/testsuite/tests/backpack/should_fail/bkpfail26.stderr
index 4c49bd1e0e..d3fd320245 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail26.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail26.stderr
@@ -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.)
diff --git a/testsuite/tests/backpack/should_fail/bkpfail27.stderr b/testsuite/tests/backpack/should_fail/bkpfail27.stderr
index b24587a2af..784ddbd7cd 100644
--- a/testsuite/tests/backpack/should_fail/bkpfail27.stderr
+++ b/testsuite/tests/backpack/should_fail/bkpfail27.stderr
@@ -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.