Fix completeness with inference variables and coercion to dynamic
commit7d6ad910bf59f33de607ef13f49f398495887a5e
authorScott Owens <sowens@fb.com>
Tue, 19 Jan 2021 10:45:30 +0000 (19 02:45 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 19 Jan 2021 10:48:12 +0000 (19 02:48 -0800)
tree6865b0295138e9d3a194173d4a837a9e65ddbaf0
parent84bd8618419d5cb4816f02a0f0f15094b18a96b4
Fix completeness with inference variables and coercion to dynamic

Summary:
When coercing to dynamic, the subtype check sets the allow_subtype_of_dynamic flag. If one of the type is an inference variable, it needs to record a constraint and remember that when satisfying that constraint later on, allow_subtype_of_dynamic should be set. This already happens for the treat_dynamic_as_bottom flag using the Typing_logic.Coerce constraint, so we just make that more flexible.

Since allow_subtype_of_dynamic and treat_dynamic_as_bottom should never both be true (the former is for coercing to dynamic, and the latter is for coercing from dynamic), these two named arguments to subtyping can be merged and renamed later on.

Also add an .mli file for Typing_logic.

Reviewed By: vsiles

Differential Revision: D25946059

fbshipit-source-id: eecaed0f8716c734e36800018210ad1eb2387d5a
hphp/hack/src/typing/typing_inference_env.ml
hphp/hack/src/typing/typing_logic.ml
hphp/hack/src/typing/typing_logic.mli [new file with mode: 0644]
hphp/hack/src/typing/typing_ordered_solver.ml
hphp/hack/src/typing/typing_print.ml
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/sound_dynamic/typing/coerce_to_dyn.good.php
hphp/hack/test/sound_dynamic/typing/infer.good.php [new file with mode: 0644]
hphp/hack/test/sound_dynamic/typing/infer.good.php.exp [new file with mode: 0644]