Check local type family instances against all imported ones
authorReid Barton <rwbarton@gmail.com>
Tue, 14 Feb 2017 18:13:37 +0000 (13:13 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 14 Feb 2017 21:57:31 +0000 (16:57 -0500)
commitbedcb71659253bb8ab5d449df8e3ee884cc85d46
tree4814ad1e37ff1cb684277ee0614c7397871c2c8e
parent392cec4da9a7ce2b5c89ac688a5b9844a543c909
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
24 files changed:
compiler/basicTypes/Name.hs
compiler/main/HscTypes.hs
compiler/typecheck/FamInst.hs
compiler/typecheck/TcRnDriver.hs
testsuite/tests/ghci/scripts/T4175.stdout
testsuite/tests/indexed-types/should_compile/T13092b/Makefile [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/T13092b/T13092b_1.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/T13092b/T13092b_2.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/T13092b/all.T [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/A.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/B.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/C.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/Main.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/Makefile [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/T13092.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092/all.T [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/Makefile [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/T13092c.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/T13092c_1.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/T13092c_2.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/T13092c_3.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/T13092c_4.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T13092c/all.T [new file with mode: 0644]
testsuite/tests/perf/compiler/all.T