Add to list of canonical unions
commit16ed9f9c35c385a8f01e7db6605c574f1d7bc363
authorShaunak Kishore <kshaunak@fb.com>
Wed, 4 Nov 2020 14:47:02 +0000 (4 06:47 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 4 Nov 2020 14:48:52 +0000 (4 06:48 -0800)
tree4a3452198a2b6e8b1f0b7717cf206e03716e869a
parent12761dd7bd4e26be8dfd929c35f37204bd571d80
Add to list of canonical unions

Summary:
HHBBC only allows certain types in its type system. It doesn't allow arbitrary union types.

In union_of, we were missing a bunch of types that will come up post the HADVAs flag-flip for HAM. These types already exist. We just weren't including them in the list of possible widened results of union_of.

In particular, TVArr|TDArr = TArr, but there's no corresponding union (short of TInitCell) for TVec|TDict. Losing this type causes type monotonicity failures, as we may infer a value as being TArrLike, drop param type checks, and then convert a union into TInitCell. In this diff, we add support for all variants of TArrLike as union types. In a follow-up, we may add TVec|TDict - but I don't think that type will matter much.

Once we start generating these array types more commonly, we find that a lot of member operations handling is broken. We need to expose methods from type-system.cpp to do append, get, and set on arbitrary array-like input types, use those in interp-minstrp.cpp, and support widening to TArrLike on mutation.

Reviewed By: arnabde03

Differential Revision: D24710387

fbshipit-source-id: 2705915e2bce8e32f716531c6d59932580d023e1
hphp/hhbbc/interp-minstr.cpp
hphp/hhbbc/type-system.cpp
hphp/hhbbc/type-system.h