Use coercion to type arithmetic/bitwise operators
commit926d4a6784669dc236331ff5c98002d8d853a70d
authorDwayne Reeves <dreeves@fb.com>
Wed, 16 Oct 2019 21:34:52 +0000 (16 14:34 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 16 Oct 2019 21:42:36 +0000 (16 14:42 -0700)
treefcc104548bac2e8cb88c82fff10ec4b1dda99bc4
parentecc3689c0040a56e1c66dc57ebf33a82d09da061
Use coercion to type arithmetic/bitwise operators

Summary: Due to usage of `Typing_utils.is_dynamic` we would allow ~T to be valid for all arithmetic and bitwise operators even if T was not a num or int. I fix this by utilizing coercion. We know that the runtime will enforce that the arithmetic/bitwise operators are a num/int so we can coerce to enforceable num/int types.

Reviewed By: vassilmladenov

Differential Revision: D17946429

fbshipit-source-id: 6566f0c18770b0c9801bec039a7ea85fdabccbd5
hphp/hack/src/typing/typing.ml
hphp/hack/test/typecheck/await_on_awaitable_type_mismatch.php.like_types.exp [deleted file]
hphp/hack/test/typecheck/disallow_array_addition.php.like_types.exp [deleted file]
hphp/hack/test/typecheck/dynamic/bad_math.php [new file with mode: 0644]
hphp/hack/test/typecheck/dynamic/bad_math.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/foreach_vector.php.like_types.exp [deleted file]