Treat array as subtype of Traversable<any>
commit2ac4c4d9ce4d371ceb53039e66474b7e23e3606d
authorAndrew Kennedy <akenn@fb.com>
Sun, 14 Apr 2019 06:17:19 +0000 (13 23:17 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Sun, 14 Apr 2019 06:20:27 +0000 (13 23:20 -0700)
tree4b40a3e654a1cb3925a400ec544f46914e5c09b3
parenta0f80c5f375426d2b3f73c0fe0b072f4f3e76dae
Treat array as subtype of Traversable<any>

Summary:
Currently, the untyped array type `array` is a subtype of `Traversable<t>` and `KeyedTraversable<t,u>` for *any* `t` and `u`.

This diff makes a small change: it is now treated as a subtype of `Traversable<_>` and `KeyedTraversable<_,_>` where `_` is the "any" type. This leads to better propagation of `_`, rather than instantiation with `[unresolved]` (under legacy checking) or `nothing` (in new inference), or unresolved type variables that later produce errors (new inference). See the new test for an example of this latter behaviour.

Reviewed By: dlreeves

Differential Revision: D14916991

fbshipit-source-id: 66d044a0bcf5462b60c3de5ba2b1bc2f056c9862
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/tast/array_filter.php.exp
hphp/hack/test/typecheck/new_inference/untyped_array.php [new file with mode: 0644]
hphp/hack/test/typecheck/new_inference/untyped_array.php.exp [new file with mode: 0644]