New inference: flatten unions when solving for lower bounds
commitab841600a2027c6fa434da30ba874ed0e7f64f37
authorAndrew Kennedy <akenn@fb.com>
Mon, 11 Feb 2019 10:24:25 +0000 (11 02:24 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Mon, 11 Feb 2019 10:29:33 +0000 (11 02:29 -0800)
treeebcb4d21fbfb46b0a168f5ed62ff8570d1556c8a
parent0daa0a4e38bd296a2f3f826f92511977a8f8b695
New inference: flatten unions when solving for lower bounds

Summary:
Currently it is possible for a solution to a type variable to contain nested unions. e.g. if we have
```
int, (string | int) <: v
```
then we will solve with `v := int | (string | int)`. Also, we might end up with spurious "circular type" errors if `v` occurs somewhere in the flattened union, even though `v | t <: v` iff `t <: v`.

So before creating the union, we normalize the set of types, flattening unions, locating `null` and nullable types, and removing `v` from the set.

Reviewed By: manzyuk

Differential Revision: D13986135

fbshipit-source-id: 847ff1083ba6501792d06e1aeb7686b066db5212
hphp/hack/src/typing/typing_subtype.ml
hphp/hack/test/typecheck/new_inference/eager_solve/circular_bug_2.php [new file with mode: 0644]
hphp/hack/test/typecheck/new_inference/eager_solve/circular_bug_2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/new_inference/transitive_simplify_2.php.exp