fix yield/generator type holes
commit1182e4f1770f658269e706de8e2c9c762f2f9f1e
authorNoam Zilberstein <noamz@fb.com>
Fri, 18 Jun 2021 18:01:38 +0000 (18 11:01 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 18 Jun 2021 18:02:48 +0000 (18 11:02 -0700)
treeb88cbb35feea0c87f4934e3189ee95c6f4a4df20
parent423dc8599d3c3bbf29bbd3020780c4c80154eb3e
fix yield/generator type holes

Summary:
This diff fixes two issues

1) It forces the return type of generator functions to be Generator or AsyncGenerator
2) It properly infers the return types of generator lambdas instead of inserting Terr

Reviewed By: madgen

Differential Revision: D28715524

fbshipit-source-id: 5531d208a703fc0e4ae2eb1ed8afc4619120c63e
31 files changed:
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_return.ml
hphp/hack/src/typing/typing_return.mli
hphp/hack/src/typing/typing_toplevel.ml
hphp/hack/test/decl/yield_deeper.php.typecheck.exp
hphp/hack/test/typecheck/continuation_is_not_awaitable2.php.exp
hphp/hack/test/typecheck/ffp/function_async_lambda_bad.php.exp
hphp/hack/test/typecheck/ffp/throw_yield.php.exp
hphp/hack/test/typecheck/ffp/yield_bad1.php.exp
hphp/hack/test/typecheck/ffp/yield_bad2.php.exp
hphp/hack/test/typecheck/functional_generator.php.exp
hphp/hack/test/typecheck/lambda/async_lambda2.php.exp
hphp/hack/test/typecheck/new_inference/async_lambda.php.exp
hphp/hack/test/typecheck/typehole/T90677577.php.exp [deleted file]
hphp/hack/test/typecheck/yield/asyncgen3.php.exp
hphp/hack/test/typecheck/yield/asyncgen4.php.exp
hphp/hack/test/typecheck/yield/asyncgen4.php.like_types.exp
hphp/hack/test/typecheck/yield/asyncgen5.php.exp
hphp/hack/test/typecheck/yield/yield_lambda1.php [moved from hphp/hack/test/typecheck/typehole/T38568222.php with 100% similarity]
hphp/hack/test/typecheck/yield/yield_lambda1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/yield/yield_lambda2.php [moved from hphp/hack/test/typecheck/typehole/T90677577.php with 100% similarity]
hphp/hack/test/typecheck/yield/yield_lambda2.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/yield/yield_lambda3.php [new file with mode: 0644]
hphp/hack/test/typecheck/yield/yield_lambda3.php.exp [moved from hphp/hack/test/typecheck/typehole/T38568222.php.exp with 100% similarity]
hphp/hack/test/typecheck/yield/yield_lambda_async.php [new file with mode: 0644]
hphp/hack/test/typecheck/yield/yield_lambda_async.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/yield/yield_send3.php.exp
hphp/hack/test/typecheck/yield/yield_send4.php.exp
hphp/hack/test/typecheck/yield/yield_wait_for_result_bad2.php.exp
hphp/hack/test/typecheck/yield_method.php [new file with mode: 0644]
hphp/hack/test/typecheck/yield_method.php.exp [new file with mode: 0644]