Typing changes for reactive functions
commit9d3e223c5c35300f08ab43fb8b888d0d416fb1d7
authorJames Wu <jjwu@fb.com>
Wed, 6 Dec 2017 18:48:26 +0000 (6 10:48 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 6 Dec 2017 19:02:39 +0000 (6 11:02 -0800)
tree0060cb69429c4ac48b6733561a3fec98a61a6ec1
parent593e622d7142f63c7102dd47224c47ce702b68da
Typing changes for reactive functions

Summary:
This adds a bunch of checks for reactive functions. Specifically:
1. Reactive functions may only call other reactive functions
2. Reactive functions may not set object properties(when we add mutability, we can allow this behavior for mutable objects)
3. Reactive functions cannot modify(append or set to) Vectors or Sets.
4. Reactive functions are subtypes of nonreactive functions, but not vice versa

This isn't all the checks we need to make for reactive functions. Namely, at least these are missing:
1. Lambdas in reactive functions are treated automatically as non-reactive for now(until we can agree on a behavior here).

Reviewed By: KendallHopkins

Differential Revision: D6317851

fbshipit-source-id: 08e0c150cfd80bb2eca160dca4bbc088a7dfdf1e
24 files changed:
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_env.ml
hphp/hack/src/typing/typing_env.mli
hphp/hack/src/typing/typing_env_types.ml
hphp/hack/src/typing/typing_env_types_sig.mli
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/src/utils/errors/errors.ml
hphp/hack/src/utils/errors/errors_sig.ml
hphp/hack/test/typecheck/reactive/reactive_calls1.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls2.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls3.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls3.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls4.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/reactive_calls4.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_lambda_reactive.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_lambda_reactive.php.exp
hphp/hack/test/typecheck/reactive/test_obj_set.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_obj_set.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_obj_set2.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_obj_set2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_obj_set3.php [new file with mode: 0644]
hphp/hack/test/typecheck/reactive/test_obj_set3.php.exp [new file with mode: 0644]