Deal with catching generic exceptions
commitd3692e66e644b5a4b6060d05d2c02de6a127110a
authorJosh Watzman <jwatzman@fb.com>
Wed, 5 Nov 2014 20:35:11 +0000 (5 12:35 -0800)
committerhhvm-bot <hhvm-bot@fb.com>
Wed, 5 Nov 2014 21:00:24 +0000 (5 13:00 -0800)
tree05ced1038f1cf448a2c911ff797a16a834540b18
parent21589c914254b1bfb4581b80f90310db8fcabeb3
Deal with catching generic exceptions

Summary: These have the same problem that `instanceof` does, that you
can't do `catch (Foo<Generic> $e)` since we don't have reified generics.
So we should do the same hack we do for `instanceof`, setting each of
the type parameters to `Tunresolved []` -- this is clearly better than
setting them to the empty list like we do now, which leads to really
weird error messages like those in the github issue.

We could also just ban generic exceptions altogether, but that seems
like a shortsighted restriction since we may want to add reified generics
at some point in the future.

Fixes https://github.com/facebook/hhvm/issues/3093

Reviewed By: @elgenie

Differential Revision: D1661066

Signature: t1:1661066:1415217726:41297e94d8546ee3aaf83ae4f4010d91ab19ccb0
hphp/hack/src/typing/typing.ml
hphp/hack/test/typecheck/generic_exception.php [new file with mode: 0644]
hphp/hack/test/typecheck/generic_exception.php.exp [new file with mode: 0644]