unify treatment of is AnyArray and is_any_array
commit8ef14c7b8c985a6053068048a4eb628fd7adc187
authorScott Owens <sowens@fb.com>
Wed, 19 Jan 2022 13:31:43 +0000 (19 05:31 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 19 Jan 2022 13:33:46 +0000 (19 05:33 -0800)
treed03901652ce04c894e81b90436da75dfeaa5d5f4
parent3d3c081ba46351e28d1e5d45dd2a2f6e65461727
unify treatment of is AnyArray and is_any_array

Summary:
Refinement for `if is_any_array(e) ...`used separate code from `if (e is AnyArray<_,_>) ...`. This makes them both use the `is` refinement code, which works better with negated types, and like types.

Add a flag `hint_first` to the refinement code because the old `is_any_array` built the intersection with the hint first, whereas the `is` code puts the hint last, and various things are sensitive to the order of intersections.

The `is_any_array` code was also buggy. For example, this should signal a type error but didn't because the `is_any_array` refinement was incorrectly setting the tpenv consistency to false. It will type error now.

```
function f(shape(...) $s, mixed $m) : void {
  if (HH\is_any_array($s)) {
    HH\idx($s, $m);
  }
}
```

Reviewed By: CatherineGasnier

Differential Revision: D32616352

fbshipit-source-id: ad50824ee6d93aa3281fec11dcf58d2200b1bb0c
hphp/hack/src/typing/typing.ml
hphp/hack/test/typecheck/anyarray.php.exp
hphp/hack/test/typecheck/is_any_array/is_any_array.php.exp