diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2017-02-12 16:02:44 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2017-02-17 13:51:19 -0800 |
commit | fd2d5b6de7493c2ff2ac76401ef296f575c52483 (patch) | |
tree | 44142c3ac7e641a1bf7980001136369394245a8a /testsuite/tests/backpack | |
parent | 22dba98f2b22141d8238d7e7a42141495945f1cf (diff) | |
download | haskell-fd2d5b6de7493c2ff2ac76401ef296f575c52483.tar.gz |
Improvements/bugfixes to signature reexport handling.
Summary:
A number of changes:
- Keep the TcGblEnv from typechecking the local signature
around when we do merging. In particular, we setup
tcg_imports and tcg_rdr_env according to the local
signature. This improves our error output (for example,
see bkpfail04) and also fixes a bug with reexporting
modules in signatures (see bkpreex07)
- Fix a bug in thinning, where if we had signature A(module A),
this previously would have *thinned out* all of the inherited
signatures. Now we treat every inherited signature as having
come from an import like "import A", so a module A reexport
will pick them up.
- Recompilation checking now keeps track of dependent source files
of the source signature; previously we forgot to retain this
info.
There's a manual update too.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: bgamari, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3133
Diffstat (limited to 'testsuite/tests/backpack')
12 files changed, 70 insertions, 6 deletions
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr index c1aa54d95e..681c541e21 100644 --- a/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr +++ b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr @@ -2,8 +2,8 @@ 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 + Main module: x :: Int + Hsig file: x :: Bool The two types are different • while merging the signatures from: • z-bkpcabal01-z-p-0.1.0.0[H=<H>]:H diff --git a/testsuite/tests/backpack/reexport/all.T b/testsuite/tests/backpack/reexport/all.T index 55a5004571..5619707e5d 100644 --- a/testsuite/tests/backpack/reexport/all.T +++ b/testsuite/tests/backpack/reexport/all.T @@ -5,3 +5,7 @@ test('bkpreex04', normal, backpack_typecheck, ['']) # These signatures are behaving badly and the renamer gets confused test('bkpreex05', expect_broken(0), backpack_typecheck, ['']) test('bkpreex06', normal, backpack_typecheck, ['']) +test('bkpreex07', normal, backpack_typecheck, ['']) +test('bkpreex08', normal, backpack_typecheck, ['']) +test('bkpreex09', normal, backpack_typecheck, ['']) +test('bkpreex10', normal, backpack_typecheck, ['']) diff --git a/testsuite/tests/backpack/reexport/bkpreex07.bkp b/testsuite/tests/backpack/reexport/bkpreex07.bkp new file mode 100644 index 0000000000..9cfb539152 --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex07.bkp @@ -0,0 +1,3 @@ +unit p where + signature A(module Prelude) where + import Prelude diff --git a/testsuite/tests/backpack/reexport/bkpreex07.stderr b/testsuite/tests/backpack/reexport/bkpreex07.stderr new file mode 100644 index 0000000000..4852528959 --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex07.stderr @@ -0,0 +1,2 @@ +[1 of 1] Processing p + [1 of 1] Compiling A[sig] ( p/A.hsig, nothing ) diff --git a/testsuite/tests/backpack/reexport/bkpreex08.bkp b/testsuite/tests/backpack/reexport/bkpreex08.bkp new file mode 100644 index 0000000000..596e5ea034 --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex08.bkp @@ -0,0 +1,17 @@ +unit q where + module B where + f = 2 :: Int +unit p2 where + dependency q + signature A(f) where + import B +unit p where + dependency q + dependency p2[A=<A>] + signature A(module A, module Prelude) where + import Prelude + f :: Int + module M where + import B + import A + g = f diff --git a/testsuite/tests/backpack/reexport/bkpreex08.stderr b/testsuite/tests/backpack/reexport/bkpreex08.stderr new file mode 100644 index 0000000000..41983efaed --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex08.stderr @@ -0,0 +1,8 @@ +[1 of 3] Processing q + Instantiating q + [1 of 1] Compiling B ( q/B.hs, nothing ) +[2 of 3] Processing p2 + [1 of 1] Compiling A[sig] ( p2/A.hsig, nothing ) +[3 of 3] Processing p + [1 of 2] Compiling A[sig] ( p/A.hsig, nothing ) + [2 of 2] Compiling M ( p/M.hs, nothing ) diff --git a/testsuite/tests/backpack/reexport/bkpreex09.bkp b/testsuite/tests/backpack/reexport/bkpreex09.bkp new file mode 100644 index 0000000000..5b16c44875 --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex09.bkp @@ -0,0 +1,10 @@ +unit p where + signature A where + f :: Bool +unit q where + dependency p[A=<A>] + signature A(module A) where + h :: Bool + module M where + import A + g = f && h diff --git a/testsuite/tests/backpack/reexport/bkpreex09.stderr b/testsuite/tests/backpack/reexport/bkpreex09.stderr new file mode 100644 index 0000000000..d4bedc39f5 --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex09.stderr @@ -0,0 +1,5 @@ +[1 of 2] Processing p + [1 of 1] Compiling A[sig] ( p/A.hsig, nothing ) +[2 of 2] Processing q + [1 of 2] Compiling A[sig] ( q/A.hsig, nothing ) + [2 of 2] Compiling M ( q/M.hs, nothing ) diff --git a/testsuite/tests/backpack/reexport/bkpreex10.bkp b/testsuite/tests/backpack/reexport/bkpreex10.bkp new file mode 100644 index 0000000000..4b00e57b5e --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex10.bkp @@ -0,0 +1,10 @@ +{-# LANGUAGE ConstraintKinds #-} +unit p where + signature A(module Data.Typeable) where + import Data.Typeable +unit q where + dependency p[A=<A>] + signature A(module A) where + module M where + import A + type X = Typeable diff --git a/testsuite/tests/backpack/reexport/bkpreex10.stderr b/testsuite/tests/backpack/reexport/bkpreex10.stderr new file mode 100644 index 0000000000..d4bedc39f5 --- /dev/null +++ b/testsuite/tests/backpack/reexport/bkpreex10.stderr @@ -0,0 +1,5 @@ +[1 of 2] Processing p + [1 of 1] Compiling A[sig] ( p/A.hsig, nothing ) +[2 of 2] Processing q + [1 of 2] Compiling A[sig] ( q/A.hsig, nothing ) + [2 of 2] Compiling M ( q/M.hs, nothing ) diff --git a/testsuite/tests/backpack/should_fail/bkpfail04.stderr b/testsuite/tests/backpack/should_fail/bkpfail04.stderr index f445c57f8e..07159cf277 100644 --- a/testsuite/tests/backpack/should_fail/bkpfail04.stderr +++ b/testsuite/tests/backpack/should_fail/bkpfail04.stderr @@ -8,8 +8,8 @@ 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} + Main module: data A = A {foo :: Int} + Hsig file: data A = A {bar :: Bool} The constructors do not match: The record label lists for ‘A’ differ The types for ‘A’ differ diff --git a/testsuite/tests/backpack/should_fail/bkpfail42.stderr b/testsuite/tests/backpack/should_fail/bkpfail42.stderr index 30b43d829e..5a9e1aa9c3 100644 --- a/testsuite/tests/backpack/should_fail/bkpfail42.stderr +++ b/testsuite/tests/backpack/should_fail/bkpfail42.stderr @@ -7,9 +7,9 @@ bkpfail42.bkp:9:9: error: • Type constructor ‘F’ has conflicting definitions in the module and its hsig file Main module: type family F a :: * - where [a] F a = GHC.Types.Int + where [a] F a = Int Hsig file: type family F a :: * - where [a] F a = GHC.Types.Bool + where [a] F a = Bool • while merging the signatures from: • p[A=<A>]:A • ...and the local signature for A |