anonymous function should not capture variables not in 'use' clause.
commit40796b2a91841fa4c4cc5d8b5990b478de2929f5
authorCatherine Gasnier <catg@fb.com>
Fri, 12 Apr 2019 17:46:16 +0000 (12 10:46 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 12 Apr 2019 17:52:46 +0000 (12 10:52 -0700)
tree7853471d80f3de7fcb73ec7e42bc2521a4f0db95
parentc247cb65a81f425cb5b66d4fbde773e7af5a18e7
anonymous function should not capture variables not in 'use' clause.

Summary:
Currently, for lambdas and anonymous functions, we stash all continuations but Next. In this diff, we also stash the Next continuation for anonymous functions and reinject variables from the use clause.

This requires to add a boolean to Efun to tell whether that's an anonymous function (not fond of this solution because that adds up to the Lfun Efun mess, so any suggestion welcome).

There are also some not so interesting changes in the helper functions in Typing_env, Typing_lenv, Typing_lenv_cont.

Reviewed By: andrewjkennedy

Differential Revision: D14664890

fbshipit-source-id: d8b62b16ba169a3c285b7a14075c4be5692ec503
30 files changed:
hphp/hack/src/annotated_ast/aast.ml
hphp/hack/src/annotated_ast/aast_mapper.ml
hphp/hack/src/naming/ast_to_nast.ml
hphp/hack/src/naming/naming.ml
hphp/hack/src/naming/nast.ml
hphp/hack/src/naming/nast_pos_mapper.ml
hphp/hack/src/typing/nastCheck.ml
hphp/hack/src/typing/nastInitCheck.ml
hphp/hack/src/typing/tast_check/basic_reactivity_check.ml
hphp/hack/src/typing/tast_typecheck.ml
hphp/hack/src/typing/tast_visitor.ml
hphp/hack/src/typing/typing.ml
hphp/hack/src/typing/typing_alias.ml
hphp/hack/src/typing/typing_env.ml
hphp/hack/src/typing/typing_env.mli
hphp/hack/src/typing/typing_lambda_ambiguous.ml
hphp/hack/src/typing/typing_sequencing.ml
hphp/hack/src/typing/typing_utils.ml
hphp/hack/test/tast/array_filter.php.exp
hphp/hack/test/tast/async_lambda.php.exp
hphp/hack/test/tast/lambda1.php.exp
hphp/hack/test/tast/lambda_contextual.php.exp
hphp/hack/test/tast/lambda_efun.php.exp
hphp/hack/test/tast/unresolved_grown_after_lambda.php.exp
hphp/hack/test/typecheck/anon_fun/anon1.php [new file with mode: 0644]
hphp/hack/test/typecheck/anon_fun/anon1.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/anon_fun/anon_expr_id.php [new file with mode: 0644]
hphp/hack/test/typecheck/anon_fun/anon_expr_id.php.exp [new file with mode: 0644]
hphp/hack/test/typecheck/anon_fun/anon_this.php [new file with mode: 0644]
hphp/hack/test/typecheck/anon_fun/anon_this.php.exp [new file with mode: 0644]