Fix handling of closed type families in Backpack.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Fri, 6 Jan 2017 04:33:02 +0000 (20:33 -0800)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Wed, 11 Jan 2017 14:54:07 +0000 (06:54 -0800)
commitf59aad6823359caf8d43730c9bc1a8b7e98719b6
treea8f57c613792f9af5ea33fec594eb898a994a706
parent8744869e3cb4a82b88e595c55f1fcc9ea1e6d0b7
Fix handling of closed type families in Backpack.

Summary:
A few related problems:

- CoAxioms, like DFuns, are implicit and never exported,
  so we have to make sure we treat them the same way as
  DFuns: in RnModIface we need to rename references to
  them with rnIfaceImplicit and in mergeSignatures we need
  to NOT check them directly for compatibility (the
  test on the type family will do this check for us.)

- But actually, we weren't checking if the axioms WERE
  consistent.  This is because we were forwarding all
  embedded CoAxiom references in the type family TyThing
  to the merged version, but that reference was what
  checkBootDeclM was using as a comparison point.
  This is similar to a problem we saw with DFuns.

  To fix this, I refactored the handling of implicit entities in TcIface
  for Backpack.  See Note [The implicit TypeEnv] for the gory details.
  Instead of passing the TypeEnv around explicitly, we stuffed it in
  IfLclEnv.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, simonpj, austin

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2928
15 files changed:
compiler/backpack/RnModIface.hs
compiler/iface/TcIface.hs
compiler/typecheck/TcBackpack.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/types/TyCon.hs
testsuite/tests/backpack/should_compile/all.T
testsuite/tests/backpack/should_compile/bkp48.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp48.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp49.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp49.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_fail/all.T
testsuite/tests/backpack/should_fail/bkpfail42.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_fail/bkpfail42.stderr [new file with mode: 0644]