OptCoercion: Ensure that TyConApps match in arity
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 8 May 2017 21:40:50 +0000 (17:40 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 8 May 2017 21:42:35 +0000 (17:42 -0400)
commit87ff5d4f0f812bad118600df0156f980b91191c5
tree86386cd345115a5a7fc12522d4cb4a0493a6b8fa
parent476307cee7ff142b0eff91d45fddf17775417814
OptCoercion: Ensure that TyConApps match in arity

Previously OptCoercion would potentially change the type of UnivCo
coercions of the shape,
```
co :: TyCon arg1 ... argN ~ TyCon arg1' ... argN'
```
where the arities of the left and right applications differ. In this
case we
would try to zip the two argument lists, meaning that one would get
truncated.

One would think this could never happen since it implies we are
applying the
same TyCon to two different numbers of arguments. However, it does
arise in the
case of applications of the `Any` tycon, which arises from the
typechecker (in
`Data.Typeable.Internal`) where we end up with an `UnsafeCo`,
```
co :: Any (Any -> Any) Any ~ Any (Any -> Any)
```

Test Plan: Validate

Reviewers: simonpj, austin, goldfire

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #13658

Differential Revision: https://phabricator.haskell.org/D3545
compiler/types/OptCoercion.hs