summaryrefslogtreecommitdiff
path: root/compiler/main/HscTypes.hs
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2017-02-14 13:13:37 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-14 16:57:31 -0500
commitbedcb71659253bb8ab5d449df8e3ee884cc85d46 (patch)
tree4814ad1e37ff1cb684277ee0614c7397871c2c8e /compiler/main/HscTypes.hs
parent392cec4da9a7ce2b5c89ac688a5b9844a543c909 (diff)
downloadhaskell-bedcb71659253bb8ab5d449df8e3ee884cc85d46.tar.gz
Check local type family instances against all imported ones
We previously checked type family instance declarations in a module for consistency with all instances that we happened to have read into the EPS or HPT. It was possible to arrange that an imported type family instance (used by an imported function) was in a module whose interface file was never read during compilation; then we wouldn't check consistency of local instances with this imported instance and as a result type safety was lost. With this patch, we still check consistency of local type family instances with all type family instances that we have loaded; but we make sure to load the interface files of all our imports that define family instances first. More selective consistency checking is left to #13102. On the other hand, we can now safely assume when we import a module that it has been checked for consistency with its imports. So we can save checking in checkFamInstConsistency, and overall we should have less work to do now. This patch also adds a note describing the Plan for ensuring type family consistency. Test Plan: Two new tests added; harbormaster Reviewers: austin, simonpj, bgamari Reviewed By: simonpj, bgamari Subscribers: ggreif, thomie Differential Revision: https://phabricator.haskell.org/D2992
Diffstat (limited to 'compiler/main/HscTypes.hs')
-rw-r--r--compiler/main/HscTypes.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 581912d518..d729dcc002 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -830,7 +830,9 @@ data ModIface
-- used when compiling this module
mi_orphan :: !WhetherHasOrphans, -- ^ Whether this module has orphans
- mi_finsts :: !WhetherHasFamInst, -- ^ Whether this module has family instances
+ mi_finsts :: !WhetherHasFamInst,
+ -- ^ Whether this module has family instances.
+ -- See Note [The type family instance consistency story].
mi_hsc_src :: !HscSource, -- ^ Boot? Signature?
mi_deps :: Dependencies,
@@ -2278,7 +2280,8 @@ data Dependencies
-- ^ Transitive closure of depended upon modules which
-- contain family instances (whether home or external).
-- This is used by 'checkFamInstConsistency'. This
- -- does NOT include us, unlike 'imp_finsts'.
+ -- does NOT include us, unlike 'imp_finsts'. See Note
+ -- [The type family instance consistency story].
}
deriving( Eq )
-- Equality used only for old/new comparison in MkIface.addFingerprints