Implement type checker enforcement to prevent array<T> <: array<int, T>
commitb334647cad18434dc6e2880b522f8dbe3e442d0a
authorMichael Tingley <tingley@fb.com>
Fri, 17 Mar 2017 00:14:57 +0000 (16 17:14 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 17 Mar 2017 00:36:20 +0000 (16 17:36 -0700)
treeeab79f45b443f1a4167634aab18f50583b655d1e
parent8e70967f2b725a7b9500b3286555daede2e2027e
Implement type checker enforcement to prevent array<T> <: array<int, T>

Summary:
When the `--safe_vector_array` type checker flag is set, this diff enforces that a vector-like array may not be used where a hashtable-like array is required.

Currently, Hack assumes the following:

```
array<T> <: array<int, T>
```

The flag makes it such that there is no subtyping relationship between `array<T>` and `array<int, T>`.

Reviewed By: eshrews

Differential Revision: D4720058

fbshipit-source-id: d492fe5d0c53c7e3cfe5385104c3f4c34d793be9
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/typecheck/array/safe_vector_array/HH_FLAGS [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_a_variable_that_may_be_an_array_of_string_when_array_of_int_to_string_is_required.php [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_a_variable_that_may_be_an_array_of_string_when_array_of_int_to_string_is_required.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_array_of_int_when_array_of_int_to_int_is_required.php [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_array_of_int_when_array_of_int_to_int_is_required.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_array_of_int_when_array_of_tk_to_tv_is_required.php [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_array_of_int_when_array_of_tk_to_tv_is_required.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_variadic_of_int_when_array_of_int_to_int_is_required.php [new file with mode: 0644]
hphp/hack/test/typecheck/array/safe_vector_array/disallows_variadic_of_int_when_array_of_int_to_int_is_required.php.exp [new file with mode: 0644]