Check InScopeSet in substTy and provide substTyUnchecked
authorBartosz Nitka <niteria@gmail.com>
Tue, 19 Jan 2016 11:25:39 +0000 (03:25 -0800)
committerBartosz Nitka <niteria@gmail.com>
Tue, 19 Jan 2016 11:26:02 +0000 (03:26 -0800)
commit9d33adb6f352ad4e488067a8756928b3778920e0
tree506b6ffa5eadb0678d7c1ba22441c46b8d4b3ac9
parent80265c4c3c827695e92dd9620faf47e064b5da37
Check InScopeSet in substTy and provide substTyUnchecked

This adds sanity checks to `substTy` that implement:

> when calling substTy subst ty it should be the case that the in-scope
> set in the substitution is a superset of
> * The free vars of the range of the substitution
> * The free vars of ty minus the domain of the substitution

and replaces violators with unchecked version. The violators were found
by running the GHC test suite.

This ensures that I can work on this incrementally and that what I fix won't
be undone by some other change.

It also includes a couple of fixes that I've already done.

Test Plan: ./validate

Reviewers: simonmar, goldfire, simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1792

GHC Trac Issues: #11371
20 files changed:
compiler/basicTypes/MkId.hs
compiler/basicTypes/VarEnv.hs
compiler/coreSyn/CoreSubst.hs
compiler/coreSyn/CoreUtils.hs
compiler/iface/BuildTyCl.hs
compiler/typecheck/Inst.hs
compiler/typecheck/TcClassDcl.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcFlatten.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcType.hs
compiler/types/FamInstEnv.hs
compiler/types/TyCoRep.hs
compiler/types/Type.hs
compiler/utils/UniqFM.hs